TypeError ajax is not a function

0 votes

I was trying to create a simple AJAX request which returns some data from a database. My function is mentioned below:

function AJAXrequest(url, postedData, callback) { 
    $.ajax({ 
            type: 'POST', 
              url: url, 
              data: postedData, 
              dataType: 'json', 
              success: callback 
      }); 
}


Here's where I call it, providing the required parameters:

AJAXrequest('voting.ajax.php', imageData, function(data) { 
// function body 

});


Yet, the callback does not run, and instead I get an error in the console:

TypeError: $.ajax(...) is not a function.


I want to know the reason why and how do I go about this?

Feb 22, 2022 in Others by Rahul
• 9,670 points
5,088 views

1 answer to this question.

0 votes

Please double-check if you're using the full-version of jquery and not some slim version as I was using the jquery cdn-script link that comes with jquery. The problem is this one by default is slim.jquery.js which doesn't have the ajax function in it. So, if you're using a copy-pasted from Bootstrap website, then the slim version jquery script link will use the full version instead.

Try using

<script src="https://code.jquery.com/jquery-3.1.1.min.js"> instead of <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"

answered Feb 22, 2022 by Aditya
• 7,680 points

Related Questions In Others

0 votes
0 answers
0 votes
0 answers

Bootstrap modal: is not a function

When I call my model in windows ...READ MORE

May 5, 2022 in Others by Kichu
• 19,050 points
6,910 views
0 votes
1 answer

Is there a way to test a formula result in excel and type it only once, all within one cell and not using a user defined function?

Use the Let function: =LET(Value,A1+B2+C4+G3+B4,IF(Value>10,"No",Value)) I hope this helps ...READ MORE

answered Jan 9, 2023 in Others by narikkadan
• 63,420 points
415 views
0 votes
1 answer

What is a name function in JavaScript & how to define it?

A named function declares a name as ...READ MORE

answered Mar 7, 2019 in Others by Frankie
• 9,830 points
4,248 views
0 votes
1 answer

Problems with JQuery $.ajax request to random.org api

You need to stringify the data yourself ...READ MORE

answered Aug 1, 2022 in Web Development by rajatha
• 7,640 points
759 views
0 votes
1 answer

jQuery AJAX submit form

There is a simple input mentioned below ...READ MORE

answered Feb 8, 2022 in Java by Soham
• 9,700 points
1,291 views
0 votes
1 answer

jQuery Ajax error handling, show custom exception messages

Make sure you're setting Response.StatusCode to something other than ...READ MORE

answered Jun 2, 2022 in JQuery by Edureka
• 13,670 points
12,078 views
0 votes
0 answers

Edit PHP query code depending on image map clicked area using AJAX

I am working on an image map ...READ MORE

Jun 3, 2022 in PHP by Kichu
• 19,050 points
275 views
0 votes
1 answer

Move_uploaded_file() function is not working

The file will be stored in a ...READ MORE

answered Feb 22, 2022 in Others by Aditya
• 7,680 points
2,701 views
0 votes
1 answer

'adb' is not recognized as an internal or external command, operable program or batch file

Set the path of adb into System ...READ MORE

answered Feb 16, 2022 in Others by Aditya
• 7,680 points
6,334 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP