score:1
Accepted answer
Since I have Access-Control-Allow-Credentials: true
in Response header, I add xhrFields: { withCredentials: true }
in $.ajax, and the cookies finally could be set.
Source code as following:
req:function(url, type, data,callback){
var path = sys.SERVER_BASE;
$.ajax({
type : type,
url : path + url,
dataType : "json",
data:data,
xhrFields: { withCredentials: true },
success : function(data){
if(callback)callback(data)
},
error:function(data){
if(callback)callback(data)
console.log('fail');
}
});
},
Related Query
- CORS response headers not working in Spray when requested from browser
- jQuery - get AJAX response headers
- Set Headers with jQuery.ajax and JSONP?
- Cookies - set across multiple domains
- Is there any way to remove Ajax headers set by setRequestHeader()?
- checkbox set to checked = false not working
- Storing and sending of http cookies not working in PhoneGap app
- Remove specific request headers set in jQuery.ajaxSetup
- Set the height of a div to be half of whatever the width is
- How to set headers to $.get() or $.post() function
- DataTable, export to pdf is not working properly with two headers and colspan
- Delete ALL Cookies with jquery and set new
- JQuery Cookies Set Expire Time
- How to get Response headers in AJAX
- How to set headers in ajax call with jquery
- Bootstrap validator not working when input field value is set with jQuery .val()
- jQuery Ajax access custom response headers
- Missing headers in response for jQuery request with CORS
- Cannot read response headers for CORS request with jQuery
- PHP JSON response contains HTML headers
- maxlength not working if value is set from js code
- Using jQuery .attr or .prop to set attribute value not working
- jQuery cross domain request response headers
- jquery-ui autocomplete: set source by callback function not working
- Webkit browsers will not allow me to set CORS preflight headers
- Error response from jQuery Validate remote isn't working
- jQuery $.cookie not reading cookie set by server response
- How to set AJAX response to jquery data table columns?
- Post response with render partial that has events is not working
- datatables 1.10 add.row() not working within ajax response
- Unable to access cookies set by another Domain in IE
- How to set a variable to a AJAX response data?
- Multiple fixed top navbar headers in Twitter Bootstrap 3 not working properly?
- jQuery Validator's "required" not working when value is set at statup
- jQuery AJAX Response Set Cookie Header
- bootstrap wysihtml5 set Value not working
- jQuery .hide() only working half the time
- CSS - Set height header/footer, with dynamic content..not working on osXsafari/iOSsafari? (jsBin)
- AJAX response not working with PHP require_once
- Set programmatic Focus on text field on iOS Is working but not showing the CURSOR
- How to set Request Headers before it being loaded in an iframe
- Set "Accept" headers in jQuery for retrieving data in iframe
- How do I include cookies within a JSON response in Rails?
- How can i read cookies in rails that have been set by jquery
- Bootstrap collapse half working on iPhone
- Set the text selection color with jQuery. Demo not working
- Goal: PHP to set object class, CSS display image based on class, make image linkable. Not working
- jQuery jsonP response headers
- post php response into div using ajax not working
- Read response headers from image error handler
More Query from same tag
- jQuery Input Mask Not Working
- What is the Mobile Safari event for the on-screen keyboard closing?
- Where is the "Hello World" coming from in Spring MVC Samples
- checking each required input for empty value with jQuery
- Jquery animation pagePiling
- Can't trigger a jquery function with scroll on a particular div
- How to place html dynamically right after the body tag but within the body tag? jQuery
- jQuery - How to get browser window to scroll horizontal when div is clicked?
- How can I match part of a string with jQuery?
- Qtip2 loads a "jquery.qtip.min.map" from internet and slows down site
- How to close the current tab in the server side button click?
- How Do I get the values of span tags
- CSS \ JS - Long li text is expanded by default (overflow should be hidden)
- jQuery multiple attribute selector with logic OR, shortcuts?
- How to make a checkbox without a form
- JQuery calling Action on Controller (But not redirecting after)
- Best practices for declaring functions inside jquery ready function
- How do I select a mouse hovered object with JQuery?
- How to refresh the data in a jqGrid?
- Cache dynamic images from array before page loads using javascript
- Very long "Wait" time on ajax requests MVC4
- AngularJS - Loading icon whilst waiting for data/data calculation
- Convert image from url to Base64
- jQueryForm (plugin) on submit do something with form -> $(this)
- Repeat jQuery ajax call
- jquery script does not execute
- old jquery version is automatically included in asp.net webforms
- I am getting bad response from file upload via Dropzone in window7
- Chrome extension unable to select DOM element
- Owl Carousel v1.3.2 with Vertical slide animation