我正在尝试在 beforeSend 事件中发送 ajax 请求之前验证 jQuery 移动应用程序中是否存在 cookie,但是执行此操作的代码行会引发以下异常:Uncaught TypeError: Object function (e,t){return new b. fn.init(e,t,r)} 没有方法 'cookie'。
我的问题:检查 jQuery 移动应用程序中是否存在 cookie 的正确方法是什么?或者这在当前版本的 jQuery 移动中是不可能的?我正在 Icenium 开发混合移动应用程序。
我正在使用的代码如下。
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();
}
}