According to Requests with credentials, Firefox will only send credentials along with cross-domain posts if
invocation.withCredentials = "true";
is set… But it doesn't seem like jQuery's Ajax API provides any mechanism for this.
Is there something I've missed? Is there some other way I can do it?
Setup your cross domain POST from JS (jQuery example): $. ajax({ type: 'POST', url: 'https://to.com/postHere.php', crossDomain: true, data: '{"some":"json"}', dataType: 'json', success: function(responseData, textStatus, jqXHR) { var value = responseData.
Browser does not allow cross domain AJAX requests due to security issues. Cross-domain requests are allowed only if the server specifies same origin security policy. To enable CORS, You need to specify below HTTP headers in the server.
xhrFields Blockquote. Type: PlainObject. An object of fieldName-fieldValue pairs to set on the native XHR object. For example, you can use it to set withCredentials to true for cross-domain requests if needed.
Functionality is supposed to be broken in jQuery 1.5.
Since jQuery 1.5.1 you should use xhrFields param.
$.ajaxSetup({ type: "POST", data: {}, dataType: 'json', xhrFields: { withCredentials: true }, crossDomain: true });
Docs: http://api.jquery.com/jQuery.ajax/
Reported bug: http://bugs.jquery.com/ticket/8146
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With