index.html:21 Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.
at HTMLInputElement.document.querySelector.onclick (http://127.0.0.1:8081/chattest/index.html:21:13)
百度和谷歌查了个遍还是不知道怎么解决。
源代码:
<h3>ajax请求</h3>
<input type="button" value="ajax请求返回xml">
document.querySelector('input').onclick = function(){
var xhr = new XMLHttpRequest();
xhr.open = ('post' , 'backxml.php');
xhr.onreadystatechange = function(){
if(xhr.readyState==4&&xhr.status==200){
console.log(xhr.responseText);
}
}
xhr.send(null);
}
```').
```php
$xmlString = file_get_contents('person.xml');
echo $xmlString;
照着B站AJAX教程打的代码,跟那个一模一样,但是我的就是运行不了,检查了十几二十遍。TAT