views:

20

answers:

1

hi

I am trying to call a web service from an ajax jquery. It is successfully entering the success method but unfortunately a 403 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

A: 

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().

jAndy
I tried accessing the web service using Soap and there were no problems...so I'm not sure
Lily