Ajax的控制台错误:ReferenceError:未定义$ [英] Console Error with Ajax: ReferenceError: $ is not defined

查看:51
本文介绍了Ajax的控制台错误:ReferenceError:未定义$的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html页面上的小脚本有问题.它只是一个函数,应该由标记中的onclick方法调用.它不起作用.每次我在浏览器中单击链接时,控制台都会显示"ReferenceError:未定义$",并指向以下代码的第三行.

i have a problem with a little script on my html page. It's just a function which should be called by an onclick method in an a tag. It dont works. Everytime i click on the link in the browser the console says "ReferenceError: $ is not defined" and points on the third line of the code below.

<script>
    function del(urlToDelete) {
        $.ajax({
            url: urlToDelete,
            type: 'DELETE',
            success: function(results) {
                location.reload();
            }
        });
    }
</script>

推荐答案

您需要为此添加jquery库.您需要包括此1st,然后编写 $.ajax 来执行.

You need to include jquery library for that.Like this. You need to include this 1st, then write $.ajax to execute.

< script src ="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

这篇关于Ajax的控制台错误:ReferenceError:未定义$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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