这是我的Ajax函数,它正在运行,但是在调用函数之后,它以HTML标记+ required_text给出响应。

值变量中的响应


<br/>
 <font size='1'>
  <table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
   <tr>
     <th align='left' bgcolor='#f57900' colspan="5">
       <span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>
         ( ! )
       </span>
        Notice: Undefined index: raw_id in C:\wamp\www\ajax\jsvarupdat\remote.php on line
         <i>
            3
         </i>
     </th>
   </tr>
 </table>
< /font>


danial”

值变量中必需

“丹尼尔”

function call_funct(str){

if (str=="")
  {
  document.getElementById("scat").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
value = xmlhttp.responseText;
    }
  }

xmlhttp.open("post","remote.php?raw_id"+str,true);
xmlhttp.send();
}

最佳答案

您代码的问题是您尚未在=上使用xmlhttp.open("post","remote.php?raw_id"+str,true);

您的代码应类似于-

function call_funct(str){

   if (str=="")
    {
          document.getElementById("scat").innerHTML="";
          return;
    }
  if (window.XMLHttpRequest)
   {
     xmlhttp=new XMLHttpRequest();
   }
  else
   {
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
  {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
       value = xmlhttp.responseText;
     }
  }

 xmlhttp.open("post","remote.php?raw_id="+str,true);
 xmlhttp.send();
}

关于javascript - Ajax:的xmlhttp.responseText响应显示完整的内部HTML,而不显示必需的文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22804406/

10-12 07:29
查看更多