I have written a web application which uses lot's of $.post
calls with JQuery. Now I would like to send withCredentials: true
with it to keep a session alive, what looks like this in $.ajax
(and also works like this):
$.ajax({
type: 'post',
url: 'http://example.com/server/api.php',
crossDomain: true,
dataType: "json",
xhrFields: {
withCredentials: true
},
data: {
username : 'test',
password : 'test'
},
success: function (d) {
$('body').html(d.status);
}
});
This is because I would now like to upload the PHP files to my server and export the client side using Cordova. (withCredentials: true
is only included because of testing on my localhost server)
Can I pack this into the $.post
call or do I need to replace all calls? (I would write a new function which would look similar to $.post)