所以我几乎一天都在努力奋斗。我想使用ajax向我的网站发出请求,所以这就是我所做的
var url = 'http://www.mywebaddress.eu/medicines/';
$.ajax({
crossDomain: true,
jsonpCallback: 'test',
headers: {
'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content')
},
url: url,
method: 'GET', // Type of response and matches what we said in the route
success: function (response) { // What to do if we succeed
// console.log(response);
// $(".animalNumber").val(response.number);
// $(".breed").val(response.name);
// var birthday = new Date(response.birthday).getTime();
// var age = getAge(birthday);
// $(".animalAge").val(age);
$('#quantity').attr({
"max": response.balance
});
},
error: function (jqXHR, textStatus, errorThrown) {
console.log("error = " + errorThrown + " " + textStatus + " " + jqXHR);
}
});
可悲的是,当我打开控制台时,我看到了这个
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at url. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). As you can see I already added this
headers: {
'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content')
},
那有什么不对?