Reputation:
Hi this is my ajax code
function GetCurrentUserId() {
return $.ajax({
type: "GET",
url: rootUrl + '/api/Common/CurrentDateAndUser',
dataType: 'json',
crossDomain: true,
success: function (data, textStatus, xmLHttpRequest) {
return data[0];
},
error: function (xhr, ajaxOptions, thrownError) {
toastr.error('Somthing is wrong', 'Error');
},
});
}
When i run this code in IE Browser then i can see this result from quick watch
See the above image, There have a some cookies
value in RequestHeader
But same time if i run my application in Chrome or Firefox
Then i got this result
I can't see any cookies values. Why? Why i can't see the cookie values when i ran my application in Chrome? How to work the ajax call with Chrome and firefox? I have spend one weeks for this work, i can't solve this. and also Stack overflow does not helps yet. Please share your knowledge to me. please dude's .
This Question related to my previous question
Web Security in IE VS Chrome & Firefox (bug)
Upvotes: 4
Views: 1000
Reputation: 7051
You need to explicitly tell IE to send the cookies to the server withCredentials: true
e.g.
$.ajaxSetup({
type: "POST",
data: {},
dataType: 'json',
xhrFields: {
withCredentials: true
}
});
Upvotes: 1