• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

ajax+php的有关问题

php 搞代码 3年前 (2022-01-23) 18次浏览 已收录 0个评论

ajax+php的问题
有好几个checkbox循环出来,还有个文本框

HTML code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->" value="<?=$row['MIS_id']?>" onclick="showInfor(this.value)" /><div id="txtHint"></div>

以下是AJAX:

JScript code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->function showInfor(str) {     //document.getElementById("txtid").value=str;    //var str = document.geElementById("ckID").value;    //document.write(str);    var xmlhttp;    if (id.length==0)      {      document.getElementById("txtid").value="";      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()      {  <p>4本文¥来源gao!%daima.com搞$代*!码$网9</p><pre>搞代gaodaima码

if (xmlhttp.readyState==4 && xmlhttp.status==200) { //document.getElementById(“show”).innerHTML=xmlhttp.responseText; document.getElementById(“txtid”).value=xmlhttp.responseText; } } xmlhttp.open(“GET”,”showSettle.php?q=”+str,true); xmlhttp.send();}

然后是对于的php页面

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$db = mysql_connect("localhost","root","1234");mysql_select_db("it database",$db);$q=$_GET['q']; // connecting to database and stuff...  echo $q;  $temp = mysql_query("SELECT MIS_id FROM materialinstorage WHERE MIS_id = '$q' "); echo $temp;$row = mysql_fetch_array($temp);  $id =$row['MIS_id'];  echo $id;

现在好像是php那页面不执行,没反应啊。
我在ajax里执行document.write(str);可以得到数据的。
请问哪里出错了呀

——解决方案——————–
弄个google浏览器或者firebug一看就知道了!
——解决方案——————–

探讨

他说我id为定义
我把ajax里的id.length==0改成了xmlhttp==null
可效果还是一样的,状态栏里也没显示网页错误了

——解决方案——————–
if (id.length==0)
这个 id 没有定义
——解决方案——————–
一步一步调试。首先alert(xmlhttp.responseText); 看能不能弹出php端的输出。
——解决方案——————–

HTML code

document.getElementById("txtid").value="";应该是这句,这是什么错啊 //跟你这句没关系的,这句只是设置文本框中的值为空if (id.length==0){  //是这段的处理,主要是id.length这个没有定义,不懂这段做什么,是判断复选框是否被选? 检查下这段      document.getElementById("txtid").value="";      return;  } 


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:ajax+php的有关问题
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址