简体   繁体   中英

Is that possible to call to external PHP script from Ajax?

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: [] (ie 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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM