0
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 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

2 Answers2

0

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 
Paul
  • 2,186
  • 20
  • 26
  • Yes, remoteUrl is being defined. the URL in dataParams is required by the api author, as they take the params and send them to that url. – user720753 Apr 22 '11 at 16:29
  • Is the URL on a different domain? Try adding crossDomain: true – Paul Apr 22 '11 at 16:32
  • Yes, the URL is on a different domain. No cigar with crossDomain. I've also tried cache: false. I tried making this api call with my firefox REST extension, and oddly enough it returns the proper JSON :(. Go figure. – user720753 Apr 22 '11 at 16:38
  • Ok try dataType: 'jsonp' and see here: http://stackoverflow.com/questions/3506208/jquery-ajax-cross-domain – Paul Apr 22 '11 at 16:50
  • Yes Paul, I changed dataType to 'jsonp', but now the ajax call switches to 'GET' instead 'POST'according to the network console tab in chrome.... – user720753 Apr 22 '11 at 18:28
  • I'm at a loss for now, unless you can give more specific details (i.e. the actual site and dummy testing login) – Paul Apr 23 '11 at 23:26
0

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 
rhesus
  • 9
  • 2