XMLHttpRequest.responseText doesnt write the value when calling a URL

前端 未结 2 862
遇见更好的自我
遇见更好的自我 2021-01-22 20:36

There may be a small error in my code. please advice me.

I want to call a URL and display the value in div on pageload.I wrote this code from SO but the responseText do

2条回答
  •  星月不相逢
    2021-01-22 21:36

    You cannot ajax a url from another domain unless it has implemented CORS

    If you need to get data from somewhere which is not same origin you need to use JSONP

    Also to debug, try calling the url from the locationbar to see if you receive valid data for your request

提交回复
热议问题