在Windows小工具中从JSON文件检索数据时出现问题
||
我正在尝试使用jquery访问存储在JSON文件(与小工具相同的文件夹)中的数据。以下示例在firefox和Internet Explorer中都可以正常运行(显示\“成功\”),但作为小工具,它不能正常工作(显示\“失败\”)。
$(\'#gadgetContent\').html(\"fail\");
$.getJSON(\"test.json\", function(data) {
$(\'#gadgetContent\').html(\"success\");
});
关于我在做什么错的任何想法吗?谢谢。
更新:
$.ajax({
url: \"test.json\",
dataType: \'json\',
error: jsonError,
success: jsonSuccess
});
function jsonError(jqXHR, textStatus, errorThrown) {
// As a gadget this function is called
// jqXHR.readyState is 4
// jqXHR.status is 0
// jqXHR.responseText is undefined
}
function jsonSuccess(data) {
// Browsers reach here
}
没有找到相关结果
已邀请:
3 个回复
铰齐插
请记住使用完整路径调用它,例如:
剃摧庭峨僳
社攻取墟槽