nipunambastha (2) [Avatar] Offline
#1
Hi guys ,

I am facing problem in getJSON

I am able to get the response, as checked from fiddler, but i am able to use the response(not able to alert the response even)

Code is:-
$(document).ready(function() {

$.getJSON("http://127.0.0.1:8001/category/1?format=json&callback=?",
function(json) {
alert(json.category);
alert("test");
});
});

Response :-
"{"Category" : [{"CategoryId" : "1","Description" : "General","Category" : "General","Name" : "nipun","Path" : "d:/testing/nipun.txt","Title" : "","PublishedDate" : "","Locked" : "False","HideInSearch" : "False","FileDesc" : ""},{"CategoryId" : "1","Description" : "General","Category" : "General","Name" : "WCFtest","Path" : "d:/testing/WCFtest.txt","Title" : "","PublishedDate" : "","Locked" : "False","HideInSearch" : "False","FileDesc" : ""}]};"

What can be probable reason?
bear.bibeault (675) [Avatar] Offline
#2
Re: getJSON
Why are all your quotes escaped in the JSON response?
nipunambastha (2) [Avatar] Offline
#3
Re: getJSON
Thats because i am converting the .net table into json
bear.bibeault (675) [Avatar] Offline
#4
Re: getJSON
The most likely cause is that the JSON is malformed. It's almost impossible to inspect visually with all the escaped quotes.

I'd bring the JSON into a text editor and start simplifying it until you find the problem.

Also, are the opening and closing quotes part of the response? They'll probably cause the whole thing to be treated as a string.