我在javascript中使用responseXML属性,但它显示xml文档($ strXml)无效的错误,我不知道我的代码中的问题在哪里,plz帮助我
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>
答案 0 :(得分:1)
我会确保XML prolog之前没有空格。 (即<?xml version="1.0" encoding="utf-8"?>
,它应该在文件的开头)
答案 1 :(得分:0)
尝试在if ($code == $codee)
之后重写代码
{
$product= $xml->createElement( 'product' );
$xml->appendChild( $product );
$pname = $xml->createElement('pname',$name);
$product->appendChild( $pname );
}
答案 2 :(得分:0)
在网址上附加时间戳,请确保获得新的xml:
var url = "coding.php?cod=" + cod+'&'+new Date().getTime();