I have a datatabe and I want to change it to json. I did that using json.net lib like this
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public object LoadTotalCallsPerCampignByRangeFilter(string fromDate, string toDate)
DataTable DTgraph = new DataTable();
....
....
string jsonformatstring = JsonConvert.SerializeObject(DTgraph, Formatting.Indented);
return jsonformatstring;
that was a webservice
then i tried to consuem it from jquery like this:
$.getJSON('http://localhost:4025/vmp_webservice.asmx/LoadTotalCallsPerCampignByRangeFilter',
{ fromDate: "01-01-2014", toDate: "09-04-2014" } )
.done(function (result) {
alert("hi");
});
I check the chrome debugging tool (f12) and I can see the request and the data returned, but the alert function is never fired.
this is the data returned.
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">[
{
"Campaign": "default",
"TotalInBound": 216.0
},
{
"Campaign": "direct",
"TotalInBound": 10.0
},
{
"Campaign": "Sales",
"TotalInBound": 151.0
},
{
"Campaign": "Support",
"TotalInBound": 2.0
}
]</string>
I see the problem that in my web service, it is returning string formated not json object
so how can I return object json not string formated json?
if the problem is something else, please tell me
thanks