Multi AJAX? – Javascript – Novawave Forums

function Req($array, $url, $divname, $a = 1)

{

// Prevar is predefined variable – such as an ID

// To set a dynamic var such as a textbox USE THIS FORMAT ‘+document.getElementById(‘box’).value+’

// For multiple AJAX requests, change the $a to a different number when calling the function

// If we are having multiple AJAX requests, we will need to generate a random requestObj ID

$ran_reqObj = “f”.md5(rand(0, 99999) * time() / rand(1, 99)); // Nice and random (requestObj)

$ran_varhttp = “v”.md5(rand(0, 99999) * time() / rand(1, 99)); // Nice and random (http)

$ran_handleResponse = “v”.md5(rand(0, 99999) * time() / rand(1, 99)); // Nice and random (handleResponse)

$urlext = “?”;

foreach($array as $key => $value)

{

$urlext .= $key.”=”.$value.”&”;

}

echo ‘

<script type=”text/javascript”>

function ‘. $ran_reqObj .’()

{

var reqObj;

var browser = navigator.appName;

if(browser == “Microsoft Internet Explorer”){

reqObj = new ActiveXObject(“Microsoft.XMLHTTP”);

}else{

reqObj = new XMLHttpRequest();

}

return reqObj;

}

var ‘. $ran_varhttp .’ = ‘. $ran_reqObj .’();

function ‘.$a.’() {

document.getElementById(“‘.$divname.’”).innerHTML = “<p align=\’center\’><img src=\’images/loader.gif\’ /></p>”;

‘. $ran_varhttp .’.open(\’get\’, \”.$url.$urlext.’\', true);

‘. $ran_varhttp .’.onreadystatechange = ‘. $ran_handleResponse .’;

‘. $ran_varhttp .’.send(null);

}

function ‘. $ran_handleResponse .’() {

if(‘. $ran_varhttp .’.readyState == 4){

var response = ‘. $ran_varhttp .’.responseText;

document.getElementById(“‘.$divname.’”).innerHTML = response;

}

}

</script>’;

return true;

}

via Multi AJAX? – Javascript – Novawave Forums.


This entry was posted in linux administration and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>