I am getting CORS error when passing x-auth-token to my ajax request. When I knock off the auth code then the CORS issue is getting resolved. But for my application, I do need the authentication and x-auth to be passed.
Below is my code:
<script>
window.onload = function() {
var username1 = 'username';
fetchData(username1);
};
function fetchData(username1) {
$.ajax({
type:'post',
url: 'http://xample.com/lcc_Overview.php',
dataType: 'json',
headers: {'Access-Control-Allow-Headers': 'Content-Type, Authorization, Content-Length, X-Requested-With'*/
'Access-Control-Allow-Origin': '*',
'x-auth-token': 'asjgkasjhgusigjkascbjhsgajghjagsdjdhhjsdhj'
},
data:
{
username:username1,
courseid:1994
},
success: function(result) {
console.log(result);
}
});
}
</script>
Can anyone suggest me why the CORS error is getting for x-auth and how it can be resolved.
Comments
Post a Comment