I am trying to verify if a cookie exists in jQuery mobile app before an ajax request gets sent in beforeSend event, but the line of code for doing this throws following exception: Uncaught TypeError: Object function (e,t){return new b.fn.init(e,t,r)} has no method 'cookie'.
My question: What is the right way to check if a cookie exists in jQuery mobile app Or this is not possible in current version of jQuery mobile? I am developing the hybrid mobile app in Icenium.
The code I am using is as below.
function CallGetEmployees() {
var serviceurl = "http://localhost:49441/WebService1.asmx/GetEmployees";
$.ajax({
url: serviceurl,
type: 'POST',
async:true,
cache:false,
dataType:"json",
beforeSend: function(xhr, opts) {
var formsCookie = $.cookie("cookie1");
if (formsCookie == null) {
xhr.abort();
clearForm();
setMode("login");
$("#sessionEnded").html("Your session has ended. Please login again.");
$("#sessionEnded").show();
}
}