Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When will a browser throw $.ajaxSetup is not a function error

Tags:

jquery

ajax

I am trying to insert following snippet in my JSP file

{
    $.ajaxSetup({
        cache: false,
        async: false
    });
    var ajax_load = "loading data please wait...";
    var loadUrl = "abc.jsp";

    $("#seoarea").html(ajax_load).load(loadUrl, {
        param1: holdvalue1,
        param2: holdvalue2
    });
}

While running this on mozilla firefox its throwing "$.ajaxSetup is not a function" error.

like image 658
blueHorizon Avatar asked Nov 30 '22 18:11

blueHorizon


2 Answers

It also can happen if you are using slim version of the library. Slim version does not include ajax.

Go here to get the latest version: https://code.jquery.com/

Credits go to Gus: TypeError: $.ajax(...) is not a function?

like image 50
Bojan Hrnkas Avatar answered Dec 02 '22 06:12

Bojan Hrnkas


This error could happen if you forgot to reference the jQuery library in your page:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>

For newest version, check this link: https://code.jquery.com/

It could also happen if you are using other js libraries such as prototypejs which also use the $ function and there could be a conflict. If this is the case you may take a look at this article on how to resolve the issue.

like image 26
Darin Dimitrov Avatar answered Dec 02 '22 07:12

Darin Dimitrov