Reputation: 11
I have problems with this function:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<title>Untitled Document</title>
<script type="text/javascript">
jQuery(document).ready(function(){
$.get("http://www.boersenpoint.de/pages/charts/shareSupplier.php?request=topFlop", { indexName: "DAX" } ,function(data){
$(data).find('share').each(function(){
alert('');
});
});
});
</script>
</head>
<body>
</body>
</html>
Firebug can not find any errors. By theory 4 alerts should appear, but the don't. Why?
Upvotes: 0
Views: 240
Reputation: 26997
$(function(){
$.get("http://www.boersenpoint.de/pages/charts/shareSupplier.php?request=topFlop", {indexName: "DAX"}, function(data) {
$(data).find('share').each(function(){
alert('');
});
});
});
There are a couple problems with your code...
data
is empty? If so, .find('share').each
would not execute ==> no alert. alert();
statement if it doesn't contain text (I don't know about the empty string as you have though, just something to keep in mind).To summarize, your specific problem in this case is the same-origin policy violation. 2. and 3. are for your benefit in future development.
Upvotes: 1
Reputation: 237817
The problem is the same-origin policy. This means that you cannot do AJAX requests to a domain unless the page you are on is also on that domain.
The easiest way to get around it would be to set up a script on your server that proxied the requests -- you make a request to your server, the server makes the request to the other server and feeds the response back to you.
If the remote server supports it, you could also use JSONP, but I doubt that is possible as the page is an XML document.
Upvotes: 1