PHP Ajax function is not working in the Win 2003 machin
I have written a ajax function in javascript (for php). It's working fine in WIN-XP machine but it's not working in Win-2003.
For onclick event I am calling the fun_LeaveLength_JS_G
function. Inside that i am setting xmlhttp2.onreadystatechange=function(). That is not executing.
My function is as follows:
function fun_LeaveLength_JS_G(dG1,dG2)
{
err2=true;
G_EmpIdFromJS=document.frmLeaveApp.txtG_EmpId.value;
G_PL_CountJS=document.frmLeaveApp.txt_PLCount.value;
PLAvailabe_JS= document.frmLeaveApp.PL_available.value;
CLAvailabe_JS=document.frmLeaveApp.CL_available.value;
LWPAvailabe_JS=document.frmLeaveApp.LWP_available.value;
MLAvailabe_JS=document.frmLeaveApp.ML_available.value;
COMPAvailabe_JS=document.frmLeaveApp.COMP_available.value;
FromHomeAvailabe_JS=document.frmLeaveApp.txt4mHome_available.value;
LeaveType_JS=document.frmLeaveApp.sltLeaveType.value;
alert(PLAvailabe_JS+" "+ CLAvailabe_JS +" "+ LWPAvailabe_JS +" "+ MLAvailabe_JS +" "+ COMPAvailabe_JS +" "+ FromHomeAvailabe_JS + " "+ LeaveType_JS);
if (dG1=="" || dG2=="")
{
return;
}
FromDate_G= dG1;
ToDate_G=dG2;
var d = new Date();
//if(str=="")
{
if (window.XMLHttpRequest)
{
xmlhttp2=new XMLHttpRequest();
}
else
{
xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp2.onreadystatechange=function()
{
alert("Before response from the AJAX");
if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
{
document.frmLeaveApp.txtLeaveLeangth.value=xmlhttp2.responseText;
alert("in ajax fileError 2 is "+err2);
alert("Ajax result is : "+xmlhttp2.responseText);
//LeaveLength_JS=xmlhttp2开发者_如何学编程.responseText();
if(xmlhttp2.responseText==1)
{
err2=true;
alert("when ajax result is 1 error 2 is "+err2);
LeaveLength_JS=xmlhttp2.responseText();
}
if(xmlhttp2.responseText==0)
{
err2=false;// allow to apply leave
alert("when ajax result is 0 error 2 is "+err2);
}
else
{
err2=true;
alert("when ajax result is other then error 2 is "+err2);
Alert("This is developer error. Please Inform to System admin");
}
}
}
xmlhttp2.open("GET","http://localhost/MyProject/LeaveLength_Ajax.php?_Get_FromDate="+FromDate_G+"&_Get_ToDate="+ToDate_G+"&PLAvailabe_JS="+PLAvailabe_JS +"&CLAvailabe_JS="+CLAvailabe_JS +"&LWPAvailabe_JS="+LWPAvailabe_JS+"&MLAvailabe_JS="+MLAvailabe_JS+"&COMPAvailabe_JS="+COMPAvailabe_JS+"&FromHomeAvailabe_JS="+FromHomeAvailabe_JS +"&LeaveType_JS="+LeaveType_JS,true);
xmlhttp2.send();
}
alert("At the end Error 2 is "+err2);
}
Where did this go wrong? Do I need to include or install any supporting software?
I don't think that the issue here has anything to do with the operating system. When you are trying this on Win2003, are you actually at that machine while testing it? Because you're trying to go query localhost
, which means that you are querying a local machine and not a network address.
Try changing this line:
xmlhttp2.open("GET","http://localhost/...")
To something like this:
xmlhttp2.open("GET","http://<server name or IP>/...")
works fine here. you are using IE6?
精彩评论