Author Topic: Ajax Call not working  (Read 3024 times)

svk123

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 9
    • View Profile
Ajax Call not working
« 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

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Ajax Call not working
« Reply #1 on: June 22, 2015, 01:38:20 pm »
use dataType: "text" instead of dataType: "json" in your Ajax call.
« Last Edit: June 22, 2015, 03:58:48 pm by paramquery »

svk123

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Ajax Call not working
« Reply #2 on: June 22, 2015, 05:09:43 pm »
changing datatype=string is putting a "\" before each " in the returned string. PQGrid constructor call fails.