I want to send data with ajax jquery to a web service in laravel 5.3. my ajax code is(URL in this question is an example):
$.ajax({
type: "POST",
url: "http://199.166.212.50:8080/.../add",
contentType:'application/json',
data: {
"requester":
{
"userName": "jac",
"password": "111"
},
"request":
{
"userName":userName,
"password":password,
"firstName": firstName,
"lastName": lastName,
"homeLocationLatLong":
{
"latitude": homeLocationLatLong_latitude,
"longitude": homeLocationLatLong_longitude
},
"homeLocationText": homeLocationText,
"homePhoneNumber": homePhoneNumber,
"cellPhoneNumber": cellPhoneNumber
}
},
dataType: "json",
success: function (result) {
console.log(result);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
})
but when i send data, i see this error:
XMLHttpRequest cannot load http://199.166.212.50:8080/.../add. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
what can i must do?