我已经创建了一个表单来获取用户的反馈,我只是想将表单数据发送到 url,但是我收到了这个错误:
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
将此行放在脚本之前的 html 页面中:
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
关于javascript - 未捕获的类型错误 : Cannot read property 'ajax' of undefined When I'm trying to send data to url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31760159/