XMLHttpRequest to get HTTP response from remote host

前端 未结 4 2005
礼貌的吻别
礼貌的吻别 2021-01-02 06:24

Why the following code Based on Mozilla example does not work? Tried with Firefox 3.5.7 & Chrome.



        
4条回答
  •  自闭症患者
    2021-01-02 06:48

    I'm also assuming that you've opened your HTML test page directly in the browser judging by your reference to file:///.... For XMLHttpRequest calls, you need to serve the HTML from a server. Try something like xampp (http://www.apachefriends.org/en/xampp.html) to get a local server up and running and then run your test from http://localhost/XMLHTTP.html.

    Note, this does not solve your same-origin problem, but this would allow the following code to work:

      
    

提交回复
热议问题