Error in Chrome only: XMLHttpRequest cannot load file URL No 'Access-Control-Allow-Origin' header is present on the requested resource

后端 未结 3 1159
南旧
南旧 2020-12-16 13:40

I am following a book example hence the code is very simple.

This is the code:

jQuery.get(\"ajax_search_results.php\",
           { s:search_query },         


        
3条回答
  •  死守一世寂寞
    2020-12-16 14:31

    This is supposedly because you trying to make cross-domain request, or something that is clarified as it. You could try adding header('Access-Control-Allow-Origin: *'); to the requested file.

    Also, such problem is sometimes occurs on server-sent events implementation in case of using event-source or XHR polling in IE 8-10 (which confused me first time).

提交回复
热议问题