无法访问 $.getJSON 函数
Not able to access the $.getJSON function
这是一个尝试访问$.getJSON的代码,但它没有响应。可能是什么原因。
function getTerms()
{
alert("hello"); //it alerts hello
$.getJSON('http://localhost/context-search.php?callback=?', function(r) {
//not here
alert("Hello");
});
}
$(document).ready(function(){
alert("hello");
getTerms();
});
上下文搜索.php以以下形式返回 JSON 数据
{"选项":["OSI","TCP","IP","HTTP Protcol","以太网","网络协议","协议含义'"]}
我哪里可能出错了??请帮助我度过难关!谢谢!!:)
您是否检查了控制台日志?如果它不包含错误,请改为执行这样的 json 请求
$.ajax({
url: url,
dataType: 'json',
data: data,
success: function(){},
error: function(jqXHR, textStatus, errorThrown) {
console.log("error " + textStatus);
console.log("incoming Text " + jqXHR.responseText);
}
});
这将为您提供适当的错误处理。
可能是同源策略。假设它在本地主机上运行,您是否尝试过
$.getJSON('/context-search.php?callback=?', ...);
这样用
法 $(document).ready(function(){
$.getJSON('/ITTA/SavePreference/?t=' + new Date(), { id: id3 },
function (data) {
if (data != null && data != undefined && data != '') {
top.location.href = '/ITTA/Entries/' + id3;
}
}); });
相关文章:
- ASP.Net AJAX$GetJson函数获胜'不要被处决
- Jquery将循环变量绑定到getJSON函数
- 如何在 window.setInterval 中每分钟运行一次 getJSON 函数
- 等效于不带jQuery的getJSON函数
- 在getJSON函数中分配一个变量
- jquery getjson 函数:回调返回错误的字符串
- 我没有从getJSON函数获得任何数据
- 无法访问 $.getJSON 函数
- 使用$. getjson()函数的空响应
- 我可以有一个递归的JavaScript函数在$.getJSON函数
- 正在尝试在$.getJSON函数之外使用JSON值
- 从getJSON函数返回值
- jquery getJSON函数未运行
- 不能访问$中的全局数组.getJSON函数
- 使用getJSON函数从while循环读取数据
- 如何从 $.getJSON 函数返回变量
- 如何在第一个 getjson 函数中的另一个 getjson 调用中使用 getjson 响应变量
- 使用 getJSon 函数将 JSON 数据解析为 html 页面
- 在$中测试布尔变量时出现奇数结果.getJSON函数
- 在getJSON函数中使用变量的值而不是变量