attempting to use asp.net page method yet returning strange json

attempting to use asp.net page method yet returning strange json

mgmg Posts: 47Questions: 0Answers: 0
edited May 2012 in General
I'm using an asp.net page method as the sAjasSource, along with fnServerData,
and while I'm able to get as far as returning data, what comes back is looking weird.

[code]{"d":{"__type":"MyApp.Project_grid+ReturnType_Project_grid",
"sEcho":[{"sEcho":"1"}],"iTotalRecords":[{"iTotalRecords":"100"}],"iTotalDisplayRecords":[{"iTotalDisplayRecords":"25"}],
"aaData":[
{"CarID":"77681597","WheelID":"2630678","State":"NJ","County":"Mercer",
{"CarID":"77681598","WheelID":"2630679","State":"NJ","County":"Camden"}
]
}}[/code]

I've tried to scour the net, but can't seem to find an end-to-end example
of using datatables with a pagemethod.

Replies

  • mgmg Posts: 47Questions: 0Answers: 0
    If there's a better way to do this, someone please let me know.

    This seemed to get things working, though:

    [code]fnCallback( jQuery.parseJSON( '{ "sEcho" : ' + parseInt(result.d.sEcho[0]["sEcho"]) + ', "iTotalRecords": ' + JSON.stringify(result.d.iTotalRecords[0]["iTotalRecords"]) + ', "iTotalDisplayRecords": ' + JSON.stringify(result.d.iTotalDisplayRecords[0]["iTotalDisplayRecords"]) + ', "aaData" : ' + JSON.stringify(result.d.aaData) + '}') )[/code]
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    That doesn't looks so good - in part you could do fnCallback( json.d ); - however, since all your inter elements are wrapped up as well, that isn't going to work. I'd suggest seeing if you can modify how the JSON structure is created.

    Allan
This discussion has been closed.