In Ajax, I'm having trouble firing several Ajax calls at the same time. It seems luck of the draw which ones fire and which ones don't. Firing them one at a time or in a sequential order - they work fine, but trying to fire them all together makes some not work. Can anyone help?
Code examples
function ajax( action )
{
var ajaxRequest;
try
{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
}
catch ( e )
{
// Internet Explorer Browsers
try
{
ajaxRequest = new ActiveXObject( 'Msxml2.XMLHTTP' );
}
catch ( e )
{
try
{
ajaxRequest = new ActiveXObject( 'Microsoft.XMLHTTP' );
}
catch ( e )
{
return FALSE;
}
}
}
// Ajax response!
ajaxRequest.onreadystatechange = function()
{
if( ajaxRequest.readyState == 4 )
{
if ( action == 'connection' )
{
// document.getElementById( 'element' ).innerHTML - ajaxRequest.responseText;
}
else if ( action == 'connection_methods_box' )
{
// document.getElementById( 'element' ).innerHTML - ajaxRequest.responseText;
}
else if ( action == 'connection_status' )
{
// document.getElementById( 'element' ).innerHTML - ajaxRequest.responseText;
}
}
}
// Send data to ajax.php
if ( action == 'connection' )
{
// Some paramaters here
}
else if ( action == 'connection_methods_box' )
{
// More paramaters
}
else if ( action == 'connection_status' )
{
// Even more
}
// Send!
var data = 'action='+action;
ajaxRequest.open( 'POST', 'ajax.php', true );
ajaxRequest.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' );
ajaxRequest.send( data );
}In ajax.php, code is similar to:
<?php
if ( $_POST['action'] == 'connection' )
{
// stuff to do
}
etc..
etc..
?>I know I could fire one Ajax query, then simply call the other once the first has finished, then the next one once the second has finished (and so on), but if possible I'd really like to fire them all at once.
Any help is appreciated.












