Here is my javascript code, very simple:

function cart_add(nid) {
  uri = get_base_url() + '?q=cart/cartadd/' + nid;
  HTTPGet(uri, cart_update_block, nid);
}

function cart_update_block(ajaxString, ajaxResult) {
  var block = $('cables_cart');
  block.innerHTML = ajaxString;
}

It gets called from this:

<a onclick="javascript: cart_add(17);" name="$nid">
<img src="/images/cart.gif" style=""/>
</a>

The GET request only gets sent the first time the image is clicked (IE), after which it seems something has gone missing. Firefox works perfectly (big surprise). Anybody see any holes? I know the that cart_add function gets called, but cart_update_block never does. No request reaches the server.

Comments

stefano@tipic.com’s picture

I guess it must be the Internet Explorer caching of GET requests. There should be a setRequestHeader in drupal.js, before the send method:

xmlHttp.open('GET', uri, bAsync);
xmlHttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
xmlHttp.send(null);
Jaza’s picture

http://www.greenash.net.au/posts/thoughts/ie_ajax_gotcha

I've been tearing my hair out over the past day, trying to figure out this bug that was occurring in the activeselect module. My blog post explains all. ;-)

Jeremy Epstein - GreenAsh

Jeremy Epstein - GreenAsh

fruzz’s picture

Aha, so that's it!

Thanks a lot Jaza!

Put the header() code in mymodule_init() as shown by Robert and it's as smooth as Jazz now.

robertdouglass’s picture

I put this code at in my module's hook_init and all is now well:


header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

I'm so sorry I didn't ask earlier... I'd have a whole day of my life left!

- Robert Douglass

-----
My Drupal book: Building Online Communities with Drupal, phpBB and WordPress