ajax request to different host

后端 未结 4 1672
逝去的感伤
逝去的感伤 2021-01-22 02:03

i have the following javascript in my webpage:

var xhr = new XMLHttpRequest();
xhr.open(\'GET\', \'http://www.google.com\', true);
xhr.onreadystatechange = funct         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-22 02:27

    does it have something to do w/ the fact that the xhr is going to a different server?

    Yep, you cannot send requests to another servers via AJAX. Whereas, you can send your requests from the server-side. Thus you'll need to implement following workflow: Your page -> Your server -> Third party server -> Your server -> Your page , where "->" means sending data.

提交回复
热议问题