NetTalk Central

Author Topic: AJAX request doesn't work in Chrome  (Read 5849 times)

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
AJAX request doesn't work in Chrome
« on: June 22, 2011, 06:07:46 AM »
JQuery Form plugin
It works in FireFox but in Google Chrome my request keeps pending and I don't get any respone.
It is just a Netwebpage procedure that returns an XML response with "do sendpacket".
The XML is correct, as I can see in FireFox.
I tried async: false and async: true . . . still not working in Chrome.

      $("#form1").ajaxForm({
         url:         'doregistreren',
         type:         'get',
         data:         '{}',
         async:         false,
         target:         '#message1',
         dataType:      'xml',
         replaceTarget:   false,
         success:      showResponse,
         error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('status:' + XMLHttpRequest.status);
            alert('responseText:' + XMLHttpRequest.responseText);
         }
      });

regards

Patrick De Laet

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: AJAX request doesn't work in Chrome - more info
« Reply #1 on: June 22, 2011, 12:19:21 PM »
It is not only Chrome - also Safari, IE and Opera doesn't work.
I've cleaned my browser's cache and now all browsers work.
What I've also found is that from time to time my SESSIONID cookie isn't send from the browser to my NetTalk server.
And it is in these cases that my AJAX requests don't work.

Anybody an idea?

POST /doRegistreren HTTP/1.1
Host: 127.0.0.1:88
Connection: keep-alive
Referer: http://127.0.0.1:88/nl/registreren
Content-Length: 354
Origin: http://127.0.0.1:88
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30
Content-Type: application/xxxx
Accept: application/json
Accept-Encoding: gzip,deflate,sdch
Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: SESSIONID=841088630

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: AJAX request doesn't work in Chrome
« Reply #2 on: June 23, 2011, 05:10:18 AM »
If it doesn't send the session value, then it's definitely not gonna get a response. The server will not allow a Session to be created via an Ajax call, and it certainly won't respond to it. This is for security reasons.

Where I've used the jQuery form plugin though, I've also had to add the following parameter -
data: {_xRequestedWithXMLHttpRequest_: true}
In some cases the jQuery form doesn't send the XMLHttpRequest header, so this helps out with that.

The missing data would be guess as to what is wrong - I'm guessing your clearing cache simply deleted the cookies, and that's taking us down the wrong path.

cheers
Bruce

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
Re: AJAX request doesn't work in Chrome
« Reply #3 on: June 23, 2011, 01:12:16 PM »
I've added  $.ajaxSetup({cache: false});
And now it seems to work in all browsers.

regards

Patrick De Laet