I am calling ajax method to Web API and it is returning json object. It contains multiple key value pairs.
I am using jquery.cookie.js from https://github.com/carhartl/jquery-cookie. In success callback I am trying to store response data into cookie, but I am getting "Uncaught TypeError: $.cookie is not a function" error.
$.ajax({
url: "http://localhost:12345/Login",
type: "Post",
contentType: "application/json",
data: (data),
headers: {
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded"
},
success: handleData,
error: function (msg) {
alert(msg);
}
});
function handleData(data) {
$.cookie("example", "foo");
$.cookie("userid", JSON.stringify(data["userid"]));
}
When I call below code in javascript tag it works. same does not work when I use same code in ajax Success callback.
$.cookie('menu-data', "Hello");
alert($.cookie("menu-data"));
i can store these data in Local storage.
Please help.
Thanks in advance.