开发者

Ajax call to web service - success in method but forbids data access

I am trying to call a web service from an ajax jquery. It is successfully entering the success method but unfortunately a 403 开发者_StackOverflow中文版error is being triggered and thus won't allow me to access the data.

This is my code:

    try {
    $.ajax({
  type: "POST",
  url: urlAddress,
  data: dataa,
  contentType: "text/xml; charset=utf-8",

  success: function(Msg) {
 //   $("#Result").text(msg.d);
    alert("ok");
    alert("hi "+Msg.responseText + " How are you?");
  },

  error: function(request, status, error) {
      alert("Error "+request.statusText.toString()); 
      alert("ERROR");
  }
});
    }
    catch (e)
    {}

Msg.ResponseText comes back "undefined"

From Live Http Headers I get the following:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Origin: null Access-Control-Request-Method: POST

HTTP/1.1 403 Forbidden Content-Length:1758 Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Date: Tue, 27 Jul 2010 10:59:04 GMT


Smells like urlAddress is not located on the same domain you're running that script.

That would breach the same origin policy and therefore, fail.

If I'm wrong here with that assumption, your're webservice might require a login (username+password) which you might missing to pass through .ajax().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜