Uncaught TypeError: Cannot read ajax property from undefined When I try to post data in url
I have created a form to get user feedback, I am just trying to submit the form data in the url, but Im getting this error:
Uncaught TypeError: Cannot read ajax property of undefined
function sendData(){
$.ajax({
url: "www.yashkjhsah.php",
type: "POST",
async: true,
data: $(".contacts_form").serialize(),
dataType: "html",
success: function(data)
{
alert(data);
if(data!="Error in Insert Query!")
{
alert("Thank you for Enquiry we will send answer in your Mail.");
}
else
{
alert("Error while saving the data");
}
}
});
}
+3
user5123500
source
to share
3 answers
The error message states that jQuery is not being defined. You must include jQuery before doing anything with $ .ajax
Place this line in your html page before your script:
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
+3
TGrif
source
to share
This means jquery has not been loaded.
Make sure you have a script in your html and also end this function call sendData
inside
$(document).ready(function(){
//do stuff
})
0
Balder
source
to share
I had the same problem and solved it by changing the dollar sign $ with jQuery .
jQuery.ajax({
type: "POST",
url: "...",
data: jQuery('myForm').serialize(),
success: function(msg) {
console.log('success!');
},
});
0
gassio
source
to share