Ajax Pattern Question

I'm not a hardcore Javascript guy but I certainly have done my fair share of coding in the past, with and without Ajax, with and without libraries, etc.

One thing that's always racked my brain is that on a page that loads multiple pieces of content in via Ajax at the same time, how do you do this without needing multiple copies of the same function? When I've tried this in the past with a function called like this:

loadIntoPage( 'IDofdiv', 'http://ajaxurl.com/returnhtml.php');

The multiple Ajax calls get all tangled up, their variables overlap, and nothing ends up displaying. But if I make multiple copies of that function (one for each Ajax-loaded block) and name all the variables differently, then it works.

I know there's a better way of doing it, so does anyone have some insight?

Leave a Reply




Created by DesignForWeb company. All rights reserved © 2007-2010. Check also the iPhone / iPad developers blog
Disclaimer
The materials collected in this blog were taken from open access sources. We try our best to preserve the copyrights of original authors and clearly state the authorship as well as link to original source website where it's possible. Please leave your comment if you feel offended by any post or if you dispose of any information about breach of copyright law in this blog. We will do our best to resolve the situation immediately.