473,698 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple XMLHttpRequest logging function

6 New Member
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 1795
Dormilich
8,658 Recognized Expert Moderator Expert
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
Steviebone
6 New Member
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 xmhtlhttpreques t 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 Recognized Expert Moderator Expert
does it change, if you define a readystatechang e handler?
Sep 10 '13 #4
Steviebone
6 New Member
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
Steviebone
6 New Member
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 readystatechang e 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 Recognized Expert Moderator Expert
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
1348
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 (favorite) { case 'nederlands' : url = 'ned.html'; break;
28
2742
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 (rlog_ostream) with such a custom streambuf. rlog is now a macro defined as #define rlog (rlog_ostream<<"<"__FUNCTION__">") so it'll log the caller's function name automatically.
2
8215
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 slowed down because five of my output fields are text fields and the expression that gets appended is a user-defined function I wrote which is very simple (just a few lines long). Here's the code of my function: Public Function tformat(num As...
2
1290
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>. Perhaps I am making it more complex than it needs to be, but I have broken down the input string into an array of single characters using preg_split(), and I am iterating through the chars, looking for a quote followed by a hash. The problem...
5
1885
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 got the first one working using 2 functions, one to apear and one to disapear. how do i keep my script simple, and just use these functions to do the same effect on the other 4 images.
5
9947
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 control points (knots). I want to use it for interpolating a cumulative distribution function. I'm looking for two simple c/c++ functions: void calculateBSpline(some_simple_data_type* bspline, double** source_points, int num_points); double...
4
6156
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 src="images/screen_print.jpg" onclick="toggle('svc_tp_1'); return true;" /> I know how to get the checkbox to check when the image is clicked, but what I really want is a toggle. When a user clicks on the image, the system should first check to see if svc_tp_1...
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.