Hi there,

Does anyone know how to force Internet Explorer to refresh it's results from an AJAX call? I might be doing something wrong but here is my problem: I use Ajax to present a form containing price values of a product from a database, where they are presented in input boxes and then the user can change them and update the database. The problem is, when I call that form again after changing the prices, Internet Explorer brings up the form with the old prices in it.

Thanks for your help,

Menster,

There's a reasonable chace that the IE is making a regular, non-AJAX HTTP request that is simply causing the page to refresh.

This typically happens because a form has action="" (or action is not specified) meaning that it defaults to self (the current page URL).

Typical, correct course of events for an AJAX request resulting from within a user event within a form, is for normal form submission to be inhibited and this is normally achieved by returning false from the form's onsubmit anon function. However, if something goes wrong (maybe a javascript error somewhere in the request half of the AJAX call) then the poor old form can get submitted - lo and behold, simple old fashioned page refresh.

The easiest way way to test for this is to explicitly set the form action to a test page (with a big message <h1>Stuff happpens</h1>). If you see the message, then the form has been submitted instead of the AJAX request.

Now all you need to do is track down the error!!

Airshow

Hi Airshow,

The problem is the page isn't refreshing either, you can call the Ajax once, and it works perfectly. Then refresh the page and call it again, it will still return the old Response String even the values in the database have changed. So it's like IE is simply caching the results of the first call and using them again when the browser sends the same request.

There is no error, (as far as I can tell, works perfect in FF & chrome) its just not re-doing the Ajax.

Menster, I can only suggest a strategy.

There are three parts to an AJAX call,

  1. Clent-side - Initiating, composing and sending a request.
  2. Server-side - Doing whatever is asked of it (eg. database lookup) and composing a response.
  3. Client-side - Receiving the response and doing something with it (typically updating some aspect of the UI).

You need to trace it through to find out exactly whrere it is breaking down with IE as the client compared to other browsers.

Here are some questions to ask.

  • Is the request being initiated, composed and sent correctly?
  • Is the server handling the request preportly?
  • If there's an update query, has the data changed?
  • Is Javascript receiving the response?
  • Is the response exactly what you would expect it to be (look for eg. unexpected white space before/after)?
  • Is the javascript addressing the DOM correctly?

You have to keep inventing debug code to test out each little theory in turn. At some point you will find some code that is misbehaving. 99% sure it will be client-side and it will be a cross-browser issue because, as you say, everything is working fine in other browsers.

Personally I would start in the middle by looking at the reponse.

Should take a couple of hours maximum. (How many times have I said that to myself?!?!?!)

Airshow

commented: Clear & Intelligent +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.