My problem is that I can not send the correct request to the server to get an answer from him in the form of a json line.
Here is my code:
$.ajax({
type: "GET",
url: url,
dataType: 'json',
crossDomain: true,
username: 'username',
password: 'password',
headers: {
'Access-Control-Allow-Origin': '*'
},
success: function(response) {
console.log(response);
}
})
When I try to send a request, I get an error:
XMLHttpRequest cannot load URL. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
var dataSet = {
username: 'username',
password: 'password',
}
$.ajax({
type: "GET",
url: url,
dataType: 'json',
crossDomain: true,
data: dataSet,
// the origin header has to be set server side
/*
headers: {
'Access-Control-Allow-Origin': '*'
},
*/
success: function(response) {
console.log(response);
}
});
parameters have assigned by a dataSet and the option data. the allow origin header has to be set server side, not in the client