jquery.ajax 不工作
我尝试使用 ajax 函数获取网页的 html,如下所示。
但它总是提示“错误”。
我不明白为什么会发生。
我还使用 firefox 中的 firebug 检查了 http 协议状态。
它显示了 200 的值。
请让我知道如何调试它。
$.ajax({
url: "http://news.naver.com/main/home.nhn",
success: function() { alert('success'); },
error: function(jqXHR, textStatus, errorThrown) { alert(textStatus); }
});
I trying to get webpage's html by using ajax function like below.
But it always alert 'error'.
I can't understand why it occur.
I also checked http protocol status using firebug in firefox.
It show me a 200 value.
Plz let me know how to debug it.
$.ajax({
url: "http://news.naver.com/main/home.nhn",
success: function() { alert('success'); },
error: function(jqXHR, textStatus, errorThrown) { alert(textStatus); }
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
naver.com 是您的网站吗?如果不是,则您无法使用 AJAX 从中检索数据,因为您只能对与您所在页面相同的域进行 AJAX 调用。
如果这不是问题,那么您需要提供更多详细信息 - 例如错误函数中参数的内容。
Is naver.com your site? If not, then you can't retrieve data from it using AJAX, since you can only make AJAX calls to the same domain as the page you're on.
If that's not the problem, then you'll need to provide more details - like what's inside your arguments in your error function.