$.ajax not working in Upgrade from Jquery 1.x to Jquery 2.x

59 Views Asked by At

I am trying to upgrade from JQyery 1.2.4 to JQuery 2.2.0 and later to 3.x.

But when updating from JQuery 1.x to 2.x, my existing $.ajax() functionality breaks. In success/ done, I am getting resonse/data as 'undefined'. But when I switch back to JQuery 1.x, then it works and captures response data.

I can see in browser's Network tab, we are getting response as expected, but still not sure why I am getting response/data as 'Undefined'.

Below is my ajax code example.

$.ajax({
    type: "GET",
    url: searchUrl,
    contentType: "application/json; charset=utf-8",
    cache: true,
})
.done(function (data) {
    console.log(data);
})
0

There are 0 best solutions below