I’m using AHAH (as outlined here http://microformats.org/wiki/rest/ahah) to make two calls to populate HTML on a page. The calls happen after the document is ready and are fired off one after another. The result, every time, is the first call gets overwritten with the last calls response. So I’ll have two of the same chunks of HTML on the page instead of two unique pieces of code. Sometimes the first call doesn’t even get to evaluate it’s call back and thus remains empty.
Any ideas?
If you’re using the exact code on that page, it’s not surprising, as the example there uses a single global variable to store the XMLHttpRequest being made. So there’s no way it can work for more than one simultaneous request: calling the function a second time overwrites the
reqwith a new one, causing thereqread byahahDoneto be the wrong request.If you want to allow this you’ll have to make
reqa local variable (by declaring itvarinfunction ahah()), and pass it with thetargetto theahahDone()function. Or just do it inline:The stuff with the browser sniffing and trying to execute script tags is hopeless and broken; don’t use it. It’s not good practice to be loading
<script>element content into the page.