In a front-end plug-in, I saw that the author's demo requested the github comment interface, but the page and interface were cross-domain. He used an ajax request, but it was different from the general writing method. I don't know how to implement it. The code is as follows, please give me some analysis.
$.ajax('https://api.github.com/repos/fex-team/xxxx/issues/81comments?per_page=100',
{
headers: {
Accept: 'application/vnd.github.full+json'
},
dataType: 'json',
success: function(data) {
console.log(data);
}
});
Generally ajax is:
$.ajax({参数...});
怪我咯2017-07-03 11:44:04
Here are two questions:
The cross-domain problem is because GitHub API already supports it. You can take a look at the CORS related headers returned by the OPTIONS request. See here for details
As for $.ajax
, both request methods are supported, namely this and this
ringa_lee2017-07-03 11:44:04
jQuery.ajax(url,[settings])
url: A URL string used to contain the request.
settings:AJAX request settings. All options are optional.