gpt4 book ai didi

javascript - 未捕获的类型错误 : Cannot read property 'ajax' of undefined When I'm trying to send data to url

转载 作者:可可西里 更新时间:2023-11-01 13:06:53 26 4
gpt4 key购买 nike

我已经创建了一个表单来获取用户的反馈,我只是想将表单数据发送到 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com