跨域异常
我在以下网址上传了我的 WordPress 博客:http://blog.in
我在调用以下网址时遇到跨域异常,
$.ajax({
type: "POST",
url: "http://app.blog.in/getToken",
contentType: "text/html",
success: function(msg) {
alert(msg);
}
});
请提出建议我
谢谢
I uploaded my wordpress blog on url : http://blog.in
I am getting cross domain exception while calling following url
$.ajax({
type: "POST",
url: "http://app.blog.in/getToken",
contentType: "text/html",
success: function(msg) {
alert(msg);
}
});
Please suggest me
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到跨域错误,因为您正在跨域:
app.blog.in
和blog.in
。您应该从与发布内容相同的域提供内容。You are getting a cross-domain error because you are crossing domains:
app.blog.in
andblog.in
. You should serve the content from the same domain as where you post it.由于您是从不同的子域加载的,因此浏览器安全不允许这样做。
除非您可以将加载的数据移动到同一域(也是同一子域),否则您应该考虑使用 JSONP.然后您可以从任何地方加载数据。
Since you are loading from a different subdomain, browser security doesn't allow that.
Unless you can move the data you're loading to the same domain (that's same subdomain as well), you should look into using JSONP. Then you can load data from anywhere.