473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

simple XMLHttpRequest logging function

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

Expand|Select|Wrap|Line Numbers
  1. var client2 = new XMLHttpRequest();
  2. client2.open("GET", "program?url=c",true);
  3. client2.send();
  4. alert('sent');
  5. return true;
however, as soon as I remove the alert() it fails in Firefox

Expand|Select|Wrap|Line Numbers
  1. var client2 = new XMLHttpRequest();
  2. client2.open("GET", "program?url=c",true);
  3. client2.send();
  4. 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... :(
Sep 10 '13 #1
6 1787
Dormilich
8,658 Expert Mod 8TB
not really a solution, but if you don’t expect a response, why not making it an sync call?

PS. I would at least send a 204 No Content Response.

PPS. how about a HEAD request instead of a GET? that doesn’t expect response content to begin with.
Sep 10 '13 #2
well i do give a response and the response is returned properly according to firebug... i just don't use it for anything, it's irrelevant..

the call needs to async so the rest of the page does not hang or pause loading

I can't understand why adding the alert() solves the problem... it's very weird. Same problem occurs whether calling xmhtlhttprequest directly or using the jquery wrapper... if I step thru the code in firebug, I can remove the alert() call and when I get to the return true the call has been fired successfully... however, as soon as a kill the breakpoints the problem returns...

thank you for your input!
Sep 10 '13 #3
Dormilich
8,658 Expert Mod 8TB
does it change, if you define a readystatechange handler?
Sep 10 '13 #4
fascinating... in every debugger using step breakpoints the function works as expected until the breakpoints are removed, then the problem returns..

and yes... I defined a handler... if the handler invokes an alert it works, no alerts, no go...

BUT! your suggestion got me thinking and I figured I should try it just to see..

setting the async to false fixes the problem... but I don't want a synchronous event... so what could the culprit be?
Sep 10 '13 #5
update:

Changing the async flag to false solves the problem apparently. (There were some random issues so I can't say that 100% definitvely yet).

However, it is confusing to me that the code runs fine in IE. Since it is a simple message to the server I dont' see how this should matter. Note that it is not the response timing that is an issue because the server never receives the request (and so therefore no reply). As near as I can tell, the send() fails for some reason with no exception or error thrown that I can find.

The logs to the server are busy but I have done several tests that indicate that the request is never received at all in these instances.

I experimented with adding a readystatechange hook even tho a reply is not needed but saw no difference.

If the problem persists I will try and craft a separate page for testing that I am able to share. Thank you for taking the time to respond. :)
Sep 11 '13 #6
Dormilich
8,658 Expert Mod 8TB
just a thought from google, do you call the page via file:// or via http:// ?
Sep 11 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: koen colen | last post by:
Hi, simple question I guess. The question is actually in the code itself as this was the simplest way to explain. .... var favorite = GetCookie('lang'); if (favorite != null) { switch...
28
by: Martin | last post by:
hi i have written a logger with the following calling syntax: rlog << "bla" << var << .... i.e. just like cout. it is done by inheriting from std::streambuf and creating an ostream object...
2
by: Mrs Howl | last post by:
I have a query that just reads one table and appends to an output table, one-for-one. No criteria. It's not a Total query (i.e. no group by). It normally run run in minutes, but gets horribly...
2
by: Daz | last post by:
Hi everyone. I am looking to create a simple function that will spot a hexcolor in a font tag, that has quotes, and remove the quotes. i.e <font color="ffffff"should become <font color=ffffff>. ...
5
by: ballygowanboy | last post by:
hi, i've got 5 thumbnail images. each one will have a brief decription, in a layer below it, set to visibility:hidden; when the user mouse overs each image, the info will be displayed. i...
5
by: happyjack27 | last post by:
I've searched the net all over. All I want to do is generate a cubic b-spline function from a set of 2-d points and evaluate it at different x. I need the kind where the curve runs through the...
4
by: ameshkin | last post by:
I have a checkbox with an ID of svc_tp_1, and an image that corresponds with this checkbox below it. <input type="checkbox" name="checkbox" id="svc_tp_1" value="svc_tp_1" / <img...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.