2014-04-02 71 views
2

這是我工作的Ajax函數,但在調用函數後,它會在HTML標記+ required_text中提供響應。Ajax:xmlhttp.responseText響應顯示完整的內部HTML而不是關閉所需文本

價值變量 「

<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> 

丹尼爾」

價值變量

「丹尼爾」

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(); 
} 
+0

精確的一兩件事請你確定你的PHP腳本沒有返回的HTML +的響應,否則包括更多的代碼。 – AMS

回答

2
需要

與您的代碼的問題是你有沒有響應在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(); 
} 
相關問題