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
• 8,980 points
25 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,280 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
• 16,250 points
16 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
702 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
363 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
• 8,730 points
77 views
0 votes
1 answer

How to simplify or automate task group creation in TFS?

You can easily import or export task ...READ MORE

answered Apr 25, 2018 in DevOps & Agile by ajs3033
• 7,280 points
819 views
0 votes
1 answer

Parse JSON in Python

import json data=json.loads(employee_data) print(data) READ MORE

answered Apr 26, 2018 in Python by aayushi
• 750 points
550 views
0 votes
1 answer

How to import data from a Json file into R?

Easy and simple: library("rjson") json_file <- "file_name" json_data <- fromJSON(file=json_file)) or ...READ MORE

answered Apr 26, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,688 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,280 points
23 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP