Usign Ajax
843833Dec 1 2008 — edited Dec 5 2008Hell guys,
I am developing an application in which I needed to use Ajax. By the help of internet I implemented it but still having some problem with it,
My code is as below::
<script language="javascript">
function postRequest(strURL)
{
var xmlHttp;
if(window.XMLHttpRequest)
{ // For Mozilla, Safari, ...
var xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{ // For Internet Explorer
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST', strURL, true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.readyState == 4)
{
updatepage(xmlHttp.responseText);
}
}
xmlHttp.send(strURL);
}
function updatepage(str)
{
var temp = str.split(":");
var pass = document.getElementById("subject");
//Logic was here.
}
function call_register()
{
var selectedcourse = window.document.frm.course.value;
//alert(selectedsubject);
var url = "Servlet?" + selectedcourse;
postRequest(url);
}
now I was used to call the function call_register() and the updation to the page were done by the function updatepage(str).
The code is working nicely. But the problem is I dont know that from where the function updatepage() is being called?
Please do reply me.
Hirav