ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: svk123 on June 20, 2015, 03:22:42 pm

Title: Ajax Call not working
Post by: svk123 on June 20, 2015, 03:22:42 pm
Hello,

I am trying to return the entire pqgrid model string including the data using an ajax call and populate the grid.
If i return the same string using sphageti code, it is showing the grid. With Ajax it is not showing.

Where could I have gone wrong?

Sphagetti code:
Code: [Select]
        var data = <%= bindgrid2() %>;
        //alert(data);
        var obj=eval('(' + data + ')');
        $grid1=$("#grid_json1").pqGrid(obj);

Ajax Call:
Code: [Select]
         $.ajax({
            type: "POST",
            url: "F1845.aspx/bindGrid2",
            data: "{}",
            processData: false,
            contentType: "application/json",
            dataType: "json",
            cache: false,
            async: true,
            success: function (msg) {
                var xyz = eval(msg.d);
                //$("#Text6").val(xyz);
                var obj = eval('(' + xyz + ')');

                //alert(obj);
                $grid1 = $("#grid_json").pqGrid(obj);


                alert("3");
                //$("#grid_json").pqGrid("refreshDataAndView");
                //alert("4");
            },
            error: function (x, e) {
                alert("The call to the server side failed. " + x.responseText);
            }
        });

alert("3") is not fired in ajax. All alerts before it get fired. I compared the two strings that are returned from the server and they are matching exactly.

Your help will be appreciated.
Thanks,
SVK
Title: Re: Ajax Call not working
Post by: paramvir on June 22, 2015, 01:38:20 pm
use dataType: "text" instead of dataType: "json" in your Ajax call.
Title: Re: Ajax Call not working
Post by: svk123 on June 22, 2015, 05:09:43 pm
changing datatype=string is putting a "\" before each " in the returned string. PQGrid constructor call fails.