I am developing a Dashboard widget for OS X. Using AJAX I am interacting with a remote API. I am using jQuery to ease the ajax implementation. The API I am working with requires a login and uses normal session cookies. I am successfully logging in but doing a subsequent AJAX call fails due to not being logged in. It appears that the widget/jQuery/ajax is not storing/using the session cookie. What am I missing?
function login(e,p) {
$.ajax({
url: url + "sessions.json",
type: "POST",
data: {
login: e,
password: p
},
success: function(res) {
getProjects();
},
dataType: 'json',
xhrFields: {
withCredentials: true
}
});
}
function getProjects() {
$.ajax({
url: url + "projects.json",
type: "GET",
data: {
},
success: function(res) {
console.log(res);
},
dataType: 'json',
xhrFields: {
withCredentials: true
}
});
}
I came across the solution to this problem while researching something else.
Phonegap App communicate with Rails 3 App using authentication