Getting HTTP 302 status code while calling a cross domain webservice?

5.2k Views Asked by At

I use jQuery to call a cross domain web service. Web service call from local host completed successfully, while calling from other domains, I got HTTP 302 status code error.

Here is web service call;

                $.ajax({
                    type: "POST",
                    url: "http://wthdevsr01:45452/webservices/GetUserAcceptancePolicyStatus.asmx/GetAcceptancePolicyReadStatus",
                    data: '{"userID" : \"' + $.trim(userID) + '\", "documentID" : \"' + $.trim(documentID) + '\"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(result) {
                        if (result.d != '') {
                            if (result.d == '1') {
                                alert("ACCEPTED");
                            }
                            else if (result.d == '0') {
                                alert("NOT ACCEPTED");
                            }
                            else {
                                alert(result.d);
                            }
                        }
                    },
                    error:function (result) {
                        alert('Service call failed: ' + result.status + '' + result.statusText);
                    }
                });

I wonder where is the problem? Any ideas?

1

There are 1 best solutions below

0
On

Probably due to the JavaScript Same Origin Policy: http://en.wikipedia.org/wiki/Same_origin_policy

You may need to use a server-side proxy on the same domain, or use something like http://www.ajax-cross-domain.com/