开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜