Reputation: 1163
<script src="jquery-1.5.2.min.js" type="text/javascript">
$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://rama.inescporto.pt/app/api/",
data: "method=getGraph&artist=Coldplay&ri=3&p=3&d=0.5",
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml) {
$('#load').fadeOut();
$(xml).find('element').each(function(){
$(".main").append('<div class="artist"><p class="id">' + $(this).find('id').text() + '</p><p class="name">' + $(this).find("name").text() + '</p><p class="rank">Published ' + $(this).find("rank").text() + '</p></div>');
$(".artist").fadeIn(1000);
});
}
</script>
</head>
<body>
<div class="main">
<div align="center" class="loader"><img src="images/loading-spiral.gif" id="load" align="absmiddle"/></div>
</div>
I think I have all correct, but the request does not happen, the success function does not kick in. Someone can see where did I get it wrong?
Upvotes: 0
Views: 3814
Reputation: 11343
Due to SOP browser rejects that request. You can use AJAX only on the same host (ip address and port), and the same protocol the original page is open from.
Edit:
If your page is here: http://rama.inescporto.pt/
make sure that you are writing a correct relative path to the page you want to get through AJAX: /app/api
.
Also, try to open http://rama.inescporto.pt/app/api/
in a browser. Do you get XML then?
Upvotes: 0