Javascript 未执行getJSON回调函数
我在一个名为reqfield.JSON的文件中有以下JSONJavascript 未执行getJSON回调函数,javascript,jquery,json,Javascript,Jquery,Json,我在一个名为reqfield.JSON的文件中有以下JSON { "Activity List View" : { "Activity Form Applet":{ "Asset Number": "Y", "Type":"Y", "Comment":"Y", "Status":"Y", "Priority":"Y" } } } 我有以下jQuery代码 $.getJSON(
{
"Activity List View" :
{
"Activity Form Applet":{
"Asset Number": "Y",
"Type":"Y",
"Comment":"Y",
"Status":"Y",
"Priority":"Y"
}
}
}
我有以下jQuery代码
$.getJSON("23030/scripts/siebel/custom/reqfield.json", function(data) {
console.log("hi");
});
但是回调函数不执行。我已经检查了firebug和chrome net选项卡,调用成功完成,并返回了json数据
还有什么问题以及如何调试它?您可能使用了错误的url/路径,但为了确保这一点,请添加几个回调函数,以便在特定情况下调用:
$.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');
});
$.getJSON(“23030/scripts/siebel/custom/reqfield.json”,函数(数据)
{
控制台日志(数据);
}).fail(函数()
{
console.log('error');
console.log(arguments);//您的文件路径正确吗?可以尝试使用/23030/scripts/siebel/custom/reqfield.json“
添加错误处理程序并查看发生了什么$.getJSON(“23030/scripts/siebel/custom/reqfield.json”,函数(数据){console.log(“hi”);})。失败(函数(jqXhr,状态,错误){警报(状态+”:“+error+”:“+jqXhr.responseText”);
@ArunPJohny无错误我在firebug get 200 OK 624msThanks中获得以下输出这帮助我调试了它。问题是缓存的json文件信息不正确。一旦我更正了json,它就开始工作了。谢谢