简体   繁体   中英

Using an API cross domain to get XML

I'm trying to get data from cdn.animenewsnetwork.com and information pertaining to the API is here . How would I access this using jQuery?

When I'm in the chrome console on the domain, it is as simple as the following:

$.ajax({
    type: "GET",
    url: "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~jin",
    dataType: 'xml',
    success: function(responseXML){
        console.log(responseXML);
    },
       error:function(results){
        console.log(results);
    }
});

I know the trick using dataType: 'jsonp' , but that doesn't work with this xml. How would I get past this?

In short unless the API supports CORS or JSONP, you will have to proxy the content through a server you control. The API docs don't mention JSONP or CORS support, so, most likely, this is not supported.

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