views:

75

answers:

1

I'm trying to call to external PHP script using Ajax like this:

$(function() {
    $.ajax({'url': 'http://stokes.chop.edu/web/zscore/result.php',
            'type': 'POST',
            'success': function(response, textStatus, XMLHttpRequest) {
                alert('[' + response + ']');
            },
            'error': function(XMLHttpRequest, textStatus, errorThrown) {
                alert('Error');
            }
    });
});

The result is: [] (i.e. success function is called!), but I see the following error in HTTPFOX plugin for FireFox:

Error loading content (NS_ERROR_DOCUMENT_NOT_CACHED)

What's wrong with my code ?

+4  A: 

You cannot load contents from pages that does not have the same domain name as the one from which the ajax request is called from. This is a well known security feature call the Same Origin Policy.

Yi Jiang
There are special mechanisms, such as [JSONP](http://en.wikipedia.org/wiki/JSON#JSONP), but they require server support.
Matthew Flaschen