I have created a form to get feedback from user, I’m simply trying to send form data to url, but I’m getting this error:
Uncaught TypeError: Cannot read property 'ajax' 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");
}
}
});
}
Best Answer
The error message says that jQuery is not define. You must include jQuery before doing anything with $.ajax
Put this line in the html page before your script :
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>