PHP Ajax函数在Win 2003 machin中不起作用

问题描述

| 我已经用javascript(对于php)编写了ajax函数。在WIN-XP机器上可以正常工作,但在Win-2003上则无法工作。 对于onclick事件,我正在调用
fun_LeaveLength_JS_G
函数。在里面,我正在设置xmlhttp2.onreadystatechange = function()。那没有执行。 我的功能如下:
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);
}
哪里出错了?我是否需要包括或安装任何支持软件?     

解决方法

        我认为这里的问题与操作系统无关。在Win2003上尝试此操作时,您实际上是在测试该计算机时在该计算机上吗?因为您要查询
localhost
,这意味着您正在查询本地计算机,而不是网络地址。 尝试更改此行:
xmlhttp2.open(\"GET\",\"http://localhost/...\")
对于这样的事情:
xmlhttp2.open(\"GET\",\"http://<server name or IP>/...\")
    ,        在这里工作正常。 您正在使用IE6?     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...