6

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.

lepe
  • 24,677
  • 9
  • 99
  • 108
blueHorizon
  • 61
  • 1
  • 1
  • 2
  • Most likely cause is that this code appears before jQuery is included on the page. Wait, no that's not right. In that case, `$` should be undefined as well, and you should see a different error `(ReferenceError)` on `$` instead of on `ajaxSetup`, unless `$` has been defined by some other code before your `ajaxSetup` code, and then jQuery comes, or jQuery is not included at all. – Anurag Jun 24 '10 at 05:45

3 Answers3

16

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?

Bojan Hrnkas
  • 1,587
  • 16
  • 22
7

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.

Bojan Hrnkas
  • 1,587
  • 16
  • 22
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0

If it's still not fixed after adding a new version of CDN. There might be somewhere Slim version linked. Check your footer carefully.

Sifat Kazi
  • 46
  • 3