0

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.

rrk
  • 15,677
  • 4
  • 29
  • 45
user2934829
  • 667
  • 1
  • 7
  • 10

1 Answers1

0

I resolved the issue. I was referencing jquery.js file in master page and as well as in content page. After removing one of this, problem got solved.

user2934829
  • 667
  • 1
  • 7
  • 10
  • mark an answer on this! http://stackoverflow.com/questions/21108375/could-not-load-file-or-assembly-system-web-webpages-razor-version-3-0-0-0-or – Alex Aug 19 '15 at 11:43