Open XML and display data in div

前端 未结 3 673
醉话见心
醉话见心 2020-12-22 05:17

I am new to xml and found this example that I load in a directory on my computer.

XML file

   
         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-22 05:46

    Edit: Ignore my answer, I didn't notice that you set async to false.

    Your problem is that you're trying to do something with the data before you actually receive it. You have to use the onreadystatechange event to capture the status and data. I'm just going to quote from MDN because they do a much better job of actually explaining it:

    [...] you need to decide what you want to do after you receive the server response to your request. At this stage, you just need to tell the HTTP request object which JavaScript function will handle processing the response. This is done by setting the onreadystatechange property of the object to the name of the JavaScript function that should be called when the state of the request changes [...]

    They have a handy guide located here: https://developer.mozilla.org/en/AJAX/Getting_Started

提交回复
热议问题