B
balakrishnan.dinesh
hi friends,
Im having a xmlhttp request function , i have put that
xmlhttp function in seperate .js file, becoz i want to reuse the
function more pages,
Code is below:
this is script 1:
<script>
var xmlhttp;
var CrossDomainPage;
var srecords1;
function xmlhttpRequest(url) /* Used to get the Response
through XmlHttp */
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null)
}
/* code for IE */
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
if (xmlhttp)
{
alert(url);
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send()
}
}
}
function state_Change()
{
/* if xmlhttp shows "loaded" */
if (xmlhttp.readyState==4)
{
/* if "OK" */
if (xmlhttp.status==200)
{
CrossDomainPage = xmlhttp.responseText;
if (CrossDomainPage == " ")
{
alert("Server is Down!!Please Wait");
return null;
}
alert("c "+CrossDomainPage); => alert must
srecords1=CrossDomainPage;
alert("srec"+srecords1); => alert must
}
else
{
alert(xmlhttp.status+"Problem retrieving
data:")
}
}
}
</scrip>
script 2: from this script only im calling the xmlhttp request function
<script>
var resp=xmlhttpRequest(url);
alert(resp); => alert must
document.write(resp)
</script>
The problem with code is,
I have specified some alerts are "alert must". the response is
printed only those alerts
are present in the code, if i take it off means ,its not displaying
anything.
And when displaying the data in tha page with those alerts, the
alert(resp) is showing null.
plz give me a suggestion, that what to be change in the code
thank u
Dinesh
Im having a xmlhttp request function , i have put that
xmlhttp function in seperate .js file, becoz i want to reuse the
function more pages,
Code is below:
this is script 1:
<script>
var xmlhttp;
var CrossDomainPage;
var srecords1;
function xmlhttpRequest(url) /* Used to get the Response
through XmlHttp */
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null)
}
/* code for IE */
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
if (xmlhttp)
{
alert(url);
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send()
}
}
}
function state_Change()
{
/* if xmlhttp shows "loaded" */
if (xmlhttp.readyState==4)
{
/* if "OK" */
if (xmlhttp.status==200)
{
CrossDomainPage = xmlhttp.responseText;
if (CrossDomainPage == " ")
{
alert("Server is Down!!Please Wait");
return null;
}
alert("c "+CrossDomainPage); => alert must
srecords1=CrossDomainPage;
alert("srec"+srecords1); => alert must
}
else
{
alert(xmlhttp.status+"Problem retrieving
data:")
}
}
}
</scrip>
script 2: from this script only im calling the xmlhttp request function
<script>
var resp=xmlhttpRequest(url);
alert(resp); => alert must
document.write(resp)
</script>
The problem with code is,
I have specified some alerts are "alert must". the response is
printed only those alerts
are present in the code, if i take it off means ,its not displaying
anything.
And when displaying the data in tha page with those alerts, the
alert(resp) is showing null.
plz give me a suggestion, that what to be change in the code
thank u
Dinesh