[英]Jquery Ajax Request Failing
var dataParams = "USER=testuser&PASSWORD=testpwd&target=https://mobilesite.com";
$.ajax({
type: 'POST',
url: remoteUrl,
data: dataParams,
success: function(data) {
console.log(data);
},
dataType: 'JSON'
}); // End of Ajax Call
I'm attempting to make an JQuery Ajax call to a remote site. 我试图对远程站点进行JQuery Ajax调用。 I'm sending a set of parameters to that site and in return I'm supposed to get a JSON formatted response back. 我正在向该站点发送一组参数,作为回报,我应该得到一个JSON格式的响应。 Actually, the call gets to the remote site which returns a 302 then redirects me to another site which in return just stays in "pending" status and kick out the below error message... 实际上,呼叫到达远程站点,该站点返回302,然后将我重定向到另一个站点,该站点返回的只是停留在“挂起”状态,并踢出以下错误消息...
"GET https://remoteUrl.com undefined (undefined)" “获取https://remoteUrl.com未定义(未定义)”
Any ideas? 有任何想法吗? Am I missing something? 我想念什么吗? I've also tried setting async to false, but that just returned an access denied. 我也尝试将async设置为false,但这只是拒绝了访问。 Thanks in advance for any help. 在此先感谢您的帮助。
Thanks 谢谢
-Delamatrix -天龙
Perhaps remove the URL from dataParams
? 也许从dataParams
删除URL? Or are you defining remoteUrl
earlier? 还是您早先定义了remoteUrl
?
Updated: 更新:
var dataParams = "USER=testuser&PASSWORD=testpwd";
var remoteUrl = "https://mobilesite.com";
$.ajax({
type: 'POST',
url: remoteUrl,
data: dataParams,
success: function(data) {
console.log(data);
},
dataType: 'jsonp',
crossDomain: true
}); // End of Ajax Call
Have you tried setting the crossdomain attribute to true (this handles redirection in jQuery 1.5+)? 您是否尝试将crossdomain属性设置为true(这在jQuery 1.5+中处理重定向)?
$.ajax({ $ .ajax({
type: 'POST',
url: remoteUrl,
crossDomain: true,
data: dataParams,
success: function(data) {
console.log(data);
},
dataType: 'JSON'
}); // End of Ajax Call
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.