我在控制台中得到这个:
Failed to load https://api.imgur.com/3/image: The 'Access-Control-Allow-Origin' header contains the invalid value ''. Origin 'https://example.org' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
var formData = new FormData();
formData.append('image', $('#imgur-api-upload')[0].files[0]);
formData.append('type', 'file');
formData.append('name', $('#imgur-api-upload')[0].files[0].name.replace('.jpg', ''));
// request
$.ajax({
async: true,
crossDomain: true,
url: 'https://api.imgur.com/3/image',
method: 'POST',
headers: {
'Authorization': 'Bearer ' + imgur_access_token
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: formData
})
.done(function(dataResponse) {
console.log(dataResponse);
if (dataResponse.hasOwnProperty('status') && dataResponse.hasOwnProperty('success')) {
if (dataResponse['success'] == true && dataResponse['status'] == 200) {
$('#episode_image').val(dataResponse['data']['link']);
} …Run Code Online (Sandbox Code Playgroud)