IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this community and its apps will no longer be available. More details available on our FAQ.
Topic
  • 3 replies
  • Latest Post - ‏2014-09-20T10:56:27Z by jitupkp
Steviebones
Steviebones
2 Posts

Pinned topic simple XMLHttpRequest logging function

‏2013-09-10T20:19:36Z | ajax jquery xmlhttprequest

I am using XMLHttpRequest as a simple one way ajax logging function. No server response is needed. The request does not cross domains.

This code works as expected in IE and in Firefox

var client2 = new XMLHttpRequest();
client2.open("GET", "program?url=c",true);
client2.send();
alert('sent');
return true;

however, as soon as I remove the alert() it fails in Firefox

var client2 = new XMLHttpRequest();
client2.open("GET", "program?url=c",true);
client2.send();
return true;

the server never receives the call...

When I step thru this in firebug, I can remove the alert line and once I step thru to the return line the function works as expected. But as soon as I eliminate the debugger (no break) it ceases to work again? very strange. no errors thrown.

I have tested this on crossbrower testing site live and determined that it is not a problem localized to my machine. The code works as expected in IE but requires the alert() to be fired in Firefox.

I tried this code with jquery.ajax with same results... in firefox, the request only works if the alert() line is present. I removed firebug, no luck. Tried corssbrowser testing again, same results...

I'm stumped... :(

  • Steviebones
    Steviebones
    2 Posts

    Re: simple XMLHttpRequest logging function

    ‏2013-09-10T21:30:56Z  

    update:

    fascinating... in every debugger using step breakpoints the function works as expected until the breakpoints are removed, then the problem returns..

    I tried defined a handler... if the handler invokes an alert() it works, no alerts, no go...

    BUT:

    setting the async to false fixes the problem... but I don't want a synchronous event... so what could the culprit be?

  • jitupkp
    jitupkp
    104 Posts

    Re: simple XMLHttpRequest logging function

    ‏2014-09-20T10:56:17Z  

    see more

    http://techgurulab.com/course/ajax-quiz-online/

  • jitupkp
    jitupkp
    104 Posts

    Re: simple XMLHttpRequest logging function

    ‏2014-09-20T10:56:27Z  

    update:

    fascinating... in every debugger using step breakpoints the function works as expected until the breakpoints are removed, then the problem returns..

    I tried defined a handler... if the handler invokes an alert() it works, no alerts, no go...

    BUT:

    setting the async to false fixes the problem... but I don't want a synchronous event... so what could the culprit be?

    see more

    http://techgurulab.com/course/ajax-quiz-online/