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.

1
  • 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, 2010 at 5:45

3 Answers 3

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?

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.

1
  • +1 - But please uses the latest version in examples! It's 1.4.2 currently, several bug fixes in there. Jun 24, 2010 at 10:48
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.