jquery ajax cross,jQuery ajax cross-domain request

博主Heather在尝试使用jQuery进行AJAX请求时,在本地环境中遇到跨域问题。她尝试了`json`和`jsonp`数据类型,但分别收到不同的错误。寻求帮助解决跨域设置、dataType选择和可能的原因。
摘要由CSDN通过智能技术生成

I am trying to make an ajax request using jQuery from my local environment.

$.ajax({

url: requestURL,

dataType: "json",

timeout: 120000,

success: function(data){

// do something

},

error: function(XMLHttpRequest, textStatus, errorThrown){

console.log("Instants.loadGame: error loading games: error text: " + textStatus + "; error thrown: " + errorThrown);

}

});

I have tried using dataType json and jsonp (as that is what everyone else seems to say fixes the problem) but I get errors either way. With dataType json the error response has textStatus = "error" and errorThrown is empty. With dataType jsonp the error response has textStatus = "parsererror" and errorThrown = "jQuery19002007321439859855_1361446807440 was not called".

I know this code works when running on the same domain as my request URL so I can only assume it is because I am doing it on my local environment. I have set my cross-domain.xml to allow everything. I am using jQuery 1.9.0.

Does anyone have any ideas? I have been looking at this a lot online but none of the solutions that helped other people seem to work for me...

Thanks,

Heather

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值