Jump to content

Multiple AJAX Requests, problem with .responseText


electricshoe

Recommended Posts

Reposted since I put it in the wrong forum!

 

 

So I use a function to create multiple requests in an array so I can use multiple ajax requests at the same time. This works great until it comes time to get the response text

 

request_array[i].onreadystatechange = function()
	{
		update_target(i,target)
	}

function update_target(request_array_key,target_to_update)
{
if (request_array[request_array_key].readyState == 4)
  		{	
		if (request_array[request_array_key].status == 200)
			{
				document.getElementById(target_to_update).className = '';
				document.getElementById(target_to_update).innerHTML = request_array[request_array_key].responseText;
			}
	}
}

 

If I create 3 requests it will run all 3 successfully, and I get all 3 returns in firebug, but it only updates the innerHTML on the last one. Why is this? It's got to be some kind of order of operations thing.

 

Thanks in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.