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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算