I am trying to fill two div tag on the body onload event.One div contains categories other contains subcategories. I am trying to trigger two functions and fill these div through ajax.I guess both functions are executed but the output of second function overwrites the first function. thus i am able to see results of only one function
This is my code:
and these are the functions:
it shows result of only the function i call second
can anyone please help me with this!!!
This is my code:
Code:
<body onLoad="showContentUsingAJAX();showContext();">
Code:
function showContentUsingAJAX()
{
urlfield = "maincategories.php"; //File path which is to be open
params = "pseudoParam="+new Date().getTime();// pseudoparams
http.open("POST", urlfield, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var results = http.responseText;
document.getElementById("id1").innerHTML = results;
//setAndExecute("DIVNAME", results);
}
}
http.send(params);
}
function showContext()
{
urlfield1 = "SUBCAT.PHP?catid=1&level=1"; //File path which is to be open
params1 = "pseudoParam="+new Date().getTime();// pseudoparams
http.open("GET", urlfield1, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params1.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var results1 = http.responseText;
document.getElementById("id2").innerHTML = results1;
//setAndExecute("DIVNAME", results);
}
}
http.send(params1);
}
can anyone please help me with this!!!
Comment