Reputation: 625
I have following JSON in a file named reqfiled.json
{
"Activity List View" :
{
"Activity Form Applet":{
"Asset Number": "Y",
"Type":"Y",
"Comment":"Y",
"Status":"Y",
"Priority":"Y"
}
}
}
I have following jQuery code
$.getJSON("23030/scripts/siebel/custom/reqfield.json", function(data) {
console.log("hi");
});
But the callback function doesn't execute. I have checked the in firebug and chrome net tab the call completed successfully and in response the json data was returned.
What else could be the problem and how to do I debug it?
Upvotes: 0
Views: 297
Reputation: 76405
You're probably using a wrong url/path, but to make sure, add a couple of callbacks to be called in specific cases:
$.getJSON("23030/scripts/siebel/custom/reqfield.json", function(data)
{
console.log(data);
}).fail(function()
{
console.log('error');
console.log(arguments);//<-- check these for clues
}).always(function()
{//add this to check if your code even gets executed...
console.log('getJSON called');
});
I'd also set a breakpoint on the console.log(data)
line (which is console.log('hi');
in your code, simply because if you say the file is indeed sent, then I'd want to know where things go wrong. Make sure the json file contains only JSON data, and also double-check the console to see any JS warnings/errors that may occur after the getJSON
call.
I haven't checked how jQ processes these json files yet, but I'm not 100% sure about your formatting. Best write out the literal in your console, and then copy-paste the output of JSON.stringify
into that file :)
Upvotes: 1