未被捕获的TypeError:无法读取属性' ajax'当我尝试将数据发送到url时未定义 [英] Uncaught TypeError: Cannot read property 'ajax' of undefined When I'm trying to send data to url
本文介绍了未被捕获的TypeError:无法读取属性' ajax'当我尝试将数据发送到url时未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个表单以获取用户反馈,我只是试图将表单数据发送到url,但是出现此错误:
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:
未捕获的TypeError:无法读取未定义的属性'ajax'
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");
}
}
});
}
推荐答案
错误消息表明未定义jQuery.在使用$ .ajax做任何事情之前,必须先包含jQuery
The error message says that jQuery is not define. You must include jQuery before doing anything with $.ajax
将此行放在html页中的脚本之前:< script src ="https://code.jquery.com/jquery-1.11.3.min.js"></script>
Put this line in the html page before your script :
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
这篇关于未被捕获的TypeError:无法读取属性&#39; ajax&#39;当我尝试将数据发送到url时未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文