未捕获的TypeError:无法读取未定义的属性'ajax'当我尝试将数据发送到url时 [英] Uncaught TypeError: Cannot read property 'ajax' of undefined When I'm trying to send data to url

查看:415
本文介绍了未捕获的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:


Uncaught 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:无法读取未定义的属性'ajax'当我尝试将数据发送到url时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆