开发者

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

开发者 https://www.devze.com 2023-02-12 05:28 出处:网络
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.

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",
 开发者_StackOverflow中文版                   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?


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号