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 },
write_results_to_page, "html");
And the code is ajax_search_results.php has:
<div id="ajax_search_results">
<ul>
<li><a href="#">First result</a></li>
<li><a href="#">Second result</a></li>
<li><a href="#">Third result</a></li>
<li><a href="#">More...</a></li>
</ul>
</div>
This works as expected in the Firefox.
But in Chrome, I can see the error following message in the JS console:
XMLHttpRequest cannot load
file:///C:/xampp/xampp/htdocs/snk/ajax_search_results.php?s=keyword.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'null' is therefore not allowed access.
Can you please help identify the problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…