I am making a mobile application using PhoneGap. To authenticate a user, I send the data using the .ajax()
command in jQuery. This sends me a cookie in return and I am able to access the cookie and the contents of the cookie.
The next step is to make another API request and this involves sending the cookie that I received in the previous step. I am trying to do something like this:
$.ajax({
url:"https://SomeDomain.asmx/getProjectList",
type:"jsonp",
xhrFields: {
withCredentials: true
},
beforeSend: function(xhr) {
xhr.setRequestHeader("Cookie", "ASP.NET_SessionId");
},
contentType: "application/json; charset=utf-8",
data: JSON.stringify(textJson),
success: function(result){
alert('success');
},
error: function(result){
console.log(result);
}
});
At the moment, the response is the text of a 404 Not Found
error page. Is it because there is something wrong with the cookie that I am attaching to the request ?
PS - I don't have access to the server side code. I'm just sending data to a web service.