views:

365

answers:

2

Its simple:

<!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>
<title></title>

<script src="jquery.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
        $.get("http://twitter.com/statuses/user_timeline/19092829.rss");
    });
</script>
</head>
<body>

</body>
</html>

In IE and Opera this works perfectly, but in FF 3.5, Chrome, and Safari I get a 400 Bad Request. Looking at the request using Fiddler2 and FireBug, something is replacing GET with OPTIONS. But in IE and Opera, it is still showing up as GET. I dont get it????

edit: i feel like such an idiot for not even thinking of xss policies. Thanks guys.

+5  A: 

You can't $.get() from a different domain. Security issues.

You can go through a proxy script on your server though. You could use PHP or C# (.NET) to get the data for you and return it to your jQuery script.

Jonathan Sampson
Mike_G
More information available in the notes of http://docs.jquery.com/Ajax/jQuery.ajax#options
Jonathan Sampson
@Mike_G For Opera and IE, you may have lowered their security level. Check my answer for Twitter-specific jQuery solution.
Adrian Godong
+2  A: 

Your script has hit a permission denied error.

Browsers have a security feature that defines which URLs you can call. Calling a URL from different domain is usually not allowed, because it will open avenues for cross site scripting attacks.

jQuery have a solution called JSONP, but that depends on the other party supplying JSONP implementation.

For Twitter, I personally used this:

$.getJSON('http://twitter.com/statuses/user_timeline/[username].json?count=10&amp;callback=?', function(data) { });
Adrian Godong