代码如下var xhr=new XMLHttpRequest(); xhr.onreadystatechange=function(){ if(xhr.readyState==4){ if((xhr.status>=200&&xhr.status<300)||xhr.status==304){ alert(xhr.responseText) var myHeader=xhr.getResponseHeader("myHeader"); console.log(myHeader) }else{ alert(xhr.status) } } }; xhr.open("GET","a.txt",true); xhr.setRequestHeader("myHeader","myValue") xhr.send(null);
添加回答
举报
0/150
提交
取消