Search code examples
jqueryjqgrid-asp.net

JQGrid not working with Query String


I have a JQGrid which is working fine, until I added QueryString to the main URL. If URL as below then JqGrid is working: http://localhost:61605/Default.aspx

If I change to: http://localhost:61605/Default.aspx/?Query1=SomeValue

Then it stops working and gives the error

PopulationjQuery(...).jqGrid is not a function

TypeError: jQuery(...).jqGrid is not a function
    at LoadGrid (http://localhost:61605/Default.aspx/?Query1=SomeValue:289:34)
    at HTMLDocument.<anonymous> (http://localhost:61605/Default.aspx/?Query1=SomeValue:223:10)
    at x.Callbacks.l (http://ajax.microsoft.com/ajax/jquery/jquery-2.0.3.min.js:4:24882)
    at Object.x.Callbacks.c.fireWith [as resolveWith] (http://ajax.microsoft.com/ajax/jquery/jquery-2.0.3.min.js:4:25702)
    at Function.x.extend.ready (http://ajax.microsoft.com/ajax/jquery/jquery-2.0.3.min.js:4:2900)
    at HTMLDocument.S (http://ajax.microsoft.com/ajax/jquery/jquery-2.0.3.min.js:4:553)

Any Idea?


Solution

  • Did you notice there's a /?

    http://localhost:61605/Default.aspx/?Query1=SomeValue
                                       ^
    

    This will change the path of jqGrid.js if you have used relative paths. Make sure either you handle this scenario or use absolute paths or paths relative to root!

    I am definitely sure that it would work, if you give the path as:

    http://localhost:61605/Default.aspx?Query1=SomeValue
    

    URL: http://localhost:61605/Default.aspx?Query1=SomeValue