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 in Others by Rahul
• 9,680 points
1,536 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 by Aditya
• 7,660 points

Related Questions In Others

0 votes
0 answers

Bootstrap modal: is not a function

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

May 5 in Others by Kichu
• 19,040 points
2,659 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
1,689 views
0 votes
1 answer

What is a callback function?

Callback function is a function which is ...READ MORE

answered Jun 13, 2019 in Others by sunshine
• 1,280 points
447 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 in Web Development by rajatha
• 7,480 points
171 views
0 votes
1 answer

jQuery AJAX submit form

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

answered Feb 8 in Java by Soham
• 9,670 points
557 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 in JQuery by Edureka
• 13,640 points
2,738 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 in PHP by Kichu
• 19,040 points
66 views
0 votes
1 answer

Move_uploaded_file() function is not working

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

answered Feb 22 in Others by Aditya
• 7,660 points
660 views
0 votes
1 answer
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