Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#4373 closed bug (worksforme)

first ajax request is sent multiple times

Reported by: fmp Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by brandon)

Afte a page is loaded the first ajax request is sent multiple times (I observed 2 - 7 times). Additional requests (without page reload) have no problem.

browsers: FF, epiphany (linux); IE7 (windows)

Code example:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<button onclick="$.post('save_defaults','')">Send</button>

Same problem with $.get $.ajax and $.post .

Could be a timing problem: In the same environment a simple page like the example above sends 2 requests, a bigger page sends 7 requests. In a different environment the simple page sends 4 requests.

Change History (7)

comment:1 Changed 10 years ago by brandon

Description: modified (diff)
Resolution: worksforme
Status: newclosed

I can't reproduce the issue you are talking about. Try to create a simplified test case to isolate the issue. Feel free to reopen with a test case.

comment:2 Changed 10 years ago by fmp

Resolution: worksforme
Status: closedreopened

As test case you can use the example code. When you click the button multiple post requests are sent to the server.

You have to look at the server access logs to observer the problem or tcpdump the network connection. You cannot see the problem in the webbrowser, as a callback function is fired only once.

The problem is critical as a server side script could do multiple inserts into a database.

comment:3 Changed 10 years ago by brandon

Resolution: worksforme
Status: reopenedclosed

The sample code you provided has a syntax error and after fixing that I'm not able to reproduce the error with this code. Please provide a more complete example that illustrates the issue.

comment:4 Changed 10 years ago by fmp

Resolution: worksforme
Status: closedreopened

I have set up an example at http://137.208.226.25:9876/test.html It has a "Send" button which does onclick="$.post('/aaa',)" . In the page there is also a link to a second page ("logtail") which shows the last 20 log lines.

With this example I always get 2 identical loglines if I load the page and press the button (tested with FF, epiphany and IE7). I also get 2 lines if I open a second browser window from the same browser instance (two FF or two IE windows on the same computer) and switch between these windows: If I open test.html, click Send, then open the logtail in a second window and again click Send in the first window, 2 lines are logged.

If the logtail is opened in a different browser only one line is logged with everey further click.

Now it gets crazy: if I load a different page from the same site in an additional browser window (http://137.208.226.25:9876 and reload this page) and click Sende, I get 3 to 7 loglines (3 with IE, 4-5 with FF, 7 with epiphany) with the first click.

With tcpdump I can also see multiple requests from my browser, therefore it should not be a server problem.

comment:5 Changed 10 years ago by brandon

I see the behavior you are experiencing on your server but using my local apache server and my server at media temple I'm unable to reproduce this issue.

Could you try to reproduce this on another server?

comment:6 Changed 10 years ago by fmp

Solved: The problem only exists if the server does not answer the ajax request. If is sends a reply, no further request is sent.

Thanks for your help!!!

comment:7 Changed 10 years ago by brandon

Resolution: worksforme
Status: reopenedclosed
Note: See TracTickets for help on using tickets.