2

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 ?

2
  • It looks like a HTTPFox bug: code.google.com/p/httpfox/issues/detail?id=20 Commented Sep 4, 2010 at 3:55
  • 1
    Lol, this would be such a gaping security hole if browsers allowed cross domain requests like that Commented Sep 4, 2010 at 7:25

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

There are special mechanisms, such as JSONP, but they require server support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.