How to load html table in asp.net not mvc ? my data comes wrong format
How to load html table in asp.net not mvc ? my data comes wrong format
HTML TABLE
-
2. 3.
4. 8. 9.A 5.B 6.C 7.
Data Format Comes from server side debug mode data
Object {d: "{"Table":[["1235876sfwer",100.00,"\/Date(147560760…76sfwer",100.00,"\/Date(1475521200000)\/"],null]}"}d: "{"Table":[["1235876sfwer",100.00,"\/Date(1475607600000)\/"],["1235876sfwer",100.00,"\/Date(1475521200000)\/"],null]}"proto: Object
Javascript Syntax
$.ajax({
type: "POST",
dataType: "json",
contentType: 'application/json; charset=utf-8',
url: '/WebForm1.aspx/GetQueryInfo',
success: function (dataa) {
debugger
$('#example').DataTable({
data: dataa
});
}
});
This question has an accepted answers - jump to answer
Answers
soooo
My guess is that you are doing something like
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string yourfunctionname (int itemId, string quantity)
{
// bunch of code left out
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.serialize(yourobject);
}
So:
If your issue is the date format, that is a valid format. You can use something like moment.js plugin to covert that format into a proper date. Or add readonly product that converts the date to a string on the server. Or, what I do, use newtonSoft (its a better serizlizer anyway). It lets you set the format of the date
As for the other issue, Ajax will deserialize the data sent back by the server. The problem is that in the above configuration, the data is actually being serialized twice, once by you, once by the web service itself. A web service can return an object without you serializing it first. Something like this:
Your data would still come back in the d object (that's Microsoft) but it would be fully serialized
Thanks