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. I'm sending a set of parameters to that site and in return I'm supposed to get a JSON formatted response back. Actually, the call gets to the remote开发者_StackOverflow中文版 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...
"GET https://remoteUrl.com undefined (undefined)"
Any ideas? Am I missing something? I've also tried setting async to false, but that just returned an access denied. Thanks in advance for any help.
Thanks
-Delamatrix
Have you tried setting the crossdomain attribute to true (this handles redirection in jQuery 1.5+)?
$.ajax({
type: 'POST',
url: remoteUrl,
crossDomain: true,
data: dataParams,
success: function(data) {
console.log(data);
},
dataType: 'JSON'
}); // End of Ajax Call
Perhaps remove the URL from dataParams
? Or are you defining remoteUrl
earlier?
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
精彩评论