I want to parse an xml document with jquery but it doesn’t return anything :
Here’s my code :
<script type="text/javascript">
$(document).ready(function(){
$(#envoi_search).click(function{
$.get("http://localhost/music.xml", { titre: "Pourtant" }, function (data){
alert("Yoo !!") ;}, "xml" );
});
});
</script>
the errors :
Uncaught ReferenceError: ajaxget is not defined
XMLHttpRequest cannot load
file:///home/mehdi/Bureau/music.xml?titre=Pourtant. Origin null is not
allowed by Access-Control-Allow-Origin.XMLHttpRequest cannot load http://localhost/music.xml?titre=Pourtant.
Origin null is not allowed by Access-Control-Allow-Origin.
Do you have any idea about that ?
Thank you 🙂
Assuming your site is also running under
localhost, try using a relative path to get your XML. Also, the selector needs to be in quotes as others have mentioned. Try this:If you are not running under local host, then you will not be able to get the XML from this URL as it will be blocked by the browsers Same Origin Policy. There are plenty of article on that if you have a Google for it.