*
The moose likes HTML, CSS and JavaScript and the fly likes Chrome sending an extra Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Chrome sending an extra "GET" with a "POST" preventing an Ajax conversation?" Watch "Chrome sending an extra "GET" with a "POST" preventing an Ajax conversation?" New topic
Author

Chrome sending an extra "GET" with a "POST" preventing an Ajax conversation?

marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

Hi

My web app, following an initial authenticated GET request, responds with the following HTML response


The ready function sends a POST request to commence an ajax conversion.

This all works fine in Opera, FireFox,IE9, however Chrome keeps sending back an extra GET request after the initial (and all subsequent) POST requests. This extra GET totally breaks the conversation (and causes the page to reset in my case)

I have checked the GET headers and they are the same for both legitimate GET and the extra GETs, so I can't filter using headers (see below)

Headers


I have googled but it does not seem to be a common problem.

Any ideas?

Thanks

Marten


when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

What's the URL of the extra GET? And your code would be a lot easier to grok if it were indented!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

Thanks

They are the same for both the intial and the extra one

first get URL:http://localhost:85/TulipTest/edu
first get URI:/TulipTest/edu
extra get URL:http://localhost:85/TulipTest/edu
extra get URI:/TulipTest/edu

I can't figure it out, I have played around with the JQuery as well, ie changing to an $.ajax(). but same result.

I'll try and indent the code

Cheers
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Copied your code and didn't see the problem:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

What is /edu returning? Is it more script that could possibly be causing a reload?
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

I have found the problem after much searching. The HTML sent to the browser by the app includes the following code

(fixed - see comment below)

Note: the offending code is the src="" in the code block.

The img with an emply src attribute is contained within a div that is hidden. The div is made visible and the image tag replaced upon a user click.

So the problem was that Chrome continues to look for an image from the server.

.... when I finally found the offending code I found an existing comment about Chrome. Initially I had programmed for the src attribute to be set dynamically but Chrome would not re render a new image. Instead I needed to use JQuery to replace the whole tag and generate a new id... anyway I go on.

I was not expecting this to be the problem.

Thanks fo you help! I would not have been able to find the problem without the Developer Tool clue, which looks pretty cool.


Marten


FYI - /edu is the url for my controller servlet, there is only one servlet for doing stuff (except for login, error, welcom, upload and download)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

marten kay wrote:
Note: a src="" does not show up in the code block.

Click the "disable HTML" checkbox when posting HTML.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Chrome sending an extra "GET" with a "POST" preventing an Ajax conversation?
 
Similar Threads
doGet and doPost() difference
Status 500 - Internal Server Error
Cannot see the JavaScript code I wrote when I hit script tab on firebug :(
http post with bpel
Some (not all!) UTF8 Characters render as "?" only from UNIX server -- works perfectly local (Win)..