tags:

views:

57

answers:

1

Hi all, I'm trying to get json working using jQuery 1.4.1 but I'm getting a null object.

Here's an example of not working code: (using $.ajax which has the 'success:' )

$.ajax({
    url: 'http://isohunt.com/js/json.php',
    dataType: 'json',
    success: function(data) {
        alert('Worked');
        alert(data);
    }
});

What is wrong with this code?

Thanks in advance

+3  A: 

You cannot ajax cross domain. You have to make proxy instead, inside your domain. Check http://www.google.com/search?q=ajax+cross+domain

yanoo
...unless you point to a jsonp enabled domain, with a cross-site callback.
karim79
I see, I'll check that link. Currently I'm only testing this in a local server, would that be a problem ?
Cornelis
yes the browser won't let you make a plain XMLHttprequest to the other domain (isohunt.com)
Pointy
The problem is that the server you're trying to contact is not your own... Regardless of remote or local.
Mike Sherov
If i were to add '?callback=?' to the url, I'm getting an error in the Firefox Console, but the first line is in fact visible... do you have any idea why it would be able to retrieve those first characters ?
Cornelis