【问题标题】:responseXML property in javascriptjavascript 中的 responseXML 属性
【发布时间】:2011-05-28 11:35:37
【问题描述】:

我在 javascript 中使用 responseXML 属性,但它显示 xml 文档 ($strXml) 无效的错误,我不知道我的代码中的问题在哪里,请帮助我

html 文件:

<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Home Page</title> 
<script type="text/javascript" src="code.js"></script> 
</head>
<body >
<form> 
<input type="text" id="code"  name="code" size="10" />
<input name="submit" type = "button" onClick ="check()"  value = "check" />
</form>
</body>
</html>

【问题讨论】:

  • 试试application/xml,而不是text/xml

标签: php javascript html xml


【解决方案1】:

我会确保 XML 序言之前没有空格。 (即&lt;?xml version="1.0" encoding="utf-8"?&gt;,应该在文档的开头)

【讨论】:

    【解决方案2】:

    尝试将if ($code == $codee)之后的代码改写为

     {
       $product= $xml->createElement( 'product' );
       $xml->appendChild( $product );
    
       $pname = $xml->createElement('pname',$name);
       $product->appendChild( $pname );
     }
    

    【讨论】:

      【解决方案3】:

      将时间戳附加到 url 确保你得到一个新的 xml:

      var url = "coding.php?cod=" + cod+'&'+new Date().getTime();
      

      【讨论】:

        猜你喜欢
        • 2015-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-16
        • 1970-01-01
        • 2011-10-21
        • 1970-01-01
        相关资源
        最近更新 更多