douben6670 2013-11-28 05:56
浏览 23
已采纳

PHP和AJAX处理变量

I'm trying to use AJAX to process information on my php page, but for some reason the first JS call doesn't seem to be executing. I've been looking at this off and on for 6 hours. Can anyone spot my mistake?

<script>
function GetData()
{
    var idNumber=document.getElementById("idNumber").value;
    var CallLetters=document.getElementById("CallLetters").value;
    var AName=document.getElementById("AName").value;
    var CName=document.getElementById("CName").value;
    var Xcoord=document.getElementById("Xcoord").value;
    var Ycoord=document.getElementById("Ycoord").value;
    var Dispos=document.getElementById("Dispos").value;
    var Comments=document.getElementById("Comments").value;
    var Packaged="&id="+idNumber+"&Call="+CallLetters+"&AN="+AName+"&CN="+CName+"&X="+Xcoord+"&Y="+Ycoord+"&Di="+Dispos+"&Comm="+Comments;
    alert(Packaged);
    showK(Packaged,'../AJAX/ajax_lookup_group.php?editSave=1','ALists');
}
</script>

<script>
function showK(strSelect,strDestination,strDIV)
{
    if (strSelect=="")
    {
        document.getElementById(strDIV).innerHTML="";
        return;
    } 
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        document.getElementById(strDIV).innerHTML=xmlhttp.responseText;
    }
}
alert(strDestination+strSelect);
xmlhttp.open("GET",strDestination+strSelect,true);
xmlhttp.send();
}
</script>

<form>
<table><tr><td>
    <input type="hidden" name="idNumber" id="idNumber" value="1">
    <input type="text" name="CallLetters" id="CallLetters" size="2" value="TES"></td>
    <td><input type="text" name="AName" id="AName" size="12" value="Testers"></td>
    <td><input type="text" name="CName" id="CName" size="12" value="TesterBob"></td>
    <td>X:<input type="text" name="Xcoord" id="Xcoord" size="2" value="333"><br>
    Y:<input type="text" name="Ycoord" id="Ycoord" size="2" value="444"></td><td style="text-align:left"><select name="Dispos" id="Dispos">
        <option value="1" selected="selected">1</option>
        <option value="0">0</option>
        <option value="2">2</option>
        </select></td><td><textarea rows="2" cols="30" name="Comments" id="Comments">we are testing</textarea></td>
    <td><input type="button" value="Save" onclick="GetData()"></td></tr>
</table>
</form>
  • 写回答

1条回答 默认 最新

  • doudian6229 2013-11-28 06:49
    关注

    The code above is on the ajax_lookup_group.php page. That page is actually a page that was called using AJAX from another parent page. The "GetData" function actually needs to be on that parent page for it to execute properly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?