相关疑难解决方法(0)

Ajax的控制台错误:ReferenceError:$未定义

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

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

javascript ajax web

3
推荐指数
1
解决办法
4万
查看次数

未捕获的ReferenceError:$未定义(ajax)

我在一个简单的jsp上有这个错误:未捕获的ReferenceError:$未定义

我只是试着回忆一下在eclipse上另一个项目的服务休息,但它似乎不起作用..

代码在这里:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <script rel="javascript" type="text/javascript" href="js/jquery-1.11.3.min.js" />

</head>

<body>
    <script>
        var people = {
            "address": "Street 12",
            "name": "twelve",
            "id": 12,
            "surname": "twelve"
        };

        function sendobject() {
            $.ajax({
                type: "POST",
                url: "http://localhost:8080/HibernateTutorialWeb/rest/person/post",
                data: markers,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(data) {
                    alert(data);
                },
                failure: function(errMsg) {
                    alert(errMsg);
                }
            });
        }
    </script>
    <input type="button" onclick="sendobject()" value="send"> </input>


</body>
</<html>
Run Code Online (Sandbox Code Playgroud)

更新:

尝试使用谷歌CDN的jQuery,但仍然无法正常工作

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

未捕获的ReferenceError:$未定义sendobject @index.jsp:15onclick …

ajax jquery

3
推荐指数
1
解决办法
2万
查看次数

使用javascript在HTML表格中显示firebase数据

我只需要用实时数据库显示数据.不添加,删除,只显示我在firebase中的数据.我需要heeeeelp:c.

这是我想用firebase信息填写的表格

这是带有信息的Firebase数据库

<html>
<body>
<style>
    table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}

th, td {
    padding: 15px;
}

table {
    border-spacing: 5px;
}

</style>

<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
<script>
  // Initialize Firebase
  var config = {
    apiKey: "AIzaSyDr2Im1C1lQvrxuQocW4ul69MKwRfc5g6g",
    authDomain: "denuncias-app.firebaseapp.com",
    databaseURL: "https://denuncias-app.firebaseio.com",
    projectId: "denuncias-app",
    storageBucket: "denuncias-app.appspot.com",
    messagingSenderId: "885651585540"
  };
  firebase.initializeApp(config);
</script>

<head>
    <title>Denuncias Municipales ASDE</title>
    </head>
<table style="width:100%">
  <tr id="tr">
    <th>Tipo de la Denuncia:</th>
    <th>Dirección:</th> 
    <th>Descripción:</th>
    <th>Correo:</th>
    <th>Creda por:</th>
    <th>Imagen</th>
    <th>Lat - Long</th>
  </tr>
  <tr> 
  </tr>
  <tr> …
Run Code Online (Sandbox Code Playgroud)

html javascript firebase firebase-realtime-database

3
推荐指数
1
解决办法
1万
查看次数

从 AJAX 调用返回的 like.js.erb 中未定义 jQuery 和 $

我正在使用带有引导程序和 webpack 的 Rails 6。一切正常。Bootstrap 工作,jQuery 工作等,直到..

我正在关注这个acts_as_votable教程:https : //blog.makersacademy.com/how-to-make-a-dynamic-rails-like-unlike-button-using-the-acts-as-votable-gem-9ab71686ff82

当 PostController 喜欢这个帖子时,它会进入 like.js.erb 然后在浏览器中返回错误

Uncaught ReferenceError: $ is not defined
  at <anonymous>:1:1
  at processResponse (rails-ujs.js:282)
  at rails-ujs.js.195
  at XMLHttpRequest.xhr.onreadystatechang (rails-ujs.js:263)
Run Code Online (Sandbox Code Playgroud)

jQuery 正在工作,因为我有引导程序工作,没有错误。只有当它通过 ajax 进入时,它似乎丢失了它。

在 PostsController 中:

Uncaught ReferenceError: $ is not defined
  at <anonymous>:1:1
  at processResponse (rails-ujs.js:282)
  at rails-ujs.js.195
  at XMLHttpRequest.xhr.onreadystatechang (rails-ujs.js:263)
Run Code Online (Sandbox Code Playgroud)

在 like.js.erb 中:

respond_to :js, :html, :json

def like
  @post = Post.find(params[:id])
  if params[:format] == 'like'
    post.liked_by current_user
  elsif params[:format] == 'unlike'
    post.unliked_by current_user
  end …
Run Code Online (Sandbox Code Playgroud)

javascript jquery ruby-on-rails

3
推荐指数
1
解决办法
1061
查看次数

onClick <a href导致未捕获的ReferenceError:$未定义?

我已经通过网站上的许多问题来解决同样的事情,但我做不到

我在代码中的onClick事件中在控制台窗口中收到以下错误:

1未捕获的ReferenceError:未定义SetName

从这一行:

$("#lstResults").append("<li><a href='#' onClick='SetName()'>" + data.d[i].title + "</" + " a>" + "</" + "li>");
Run Code Online (Sandbox Code Playgroud)

我已经通过Uncaught ReferenceError工作:$未定义?试图找到问题和其他几个没有运气的人.

我试过了:

  1. 确保我的CSS高于我的.js文件.
  2. 确保我引用jquery
  3. 确保在jquery之后列出我的其他.js文件
  4. 将对jquery的引用更改为http或https或将其剥离并将其保留为//代码.
  5. 确保我的两个函数都在$(function(){中
  6. 移动我试图用onClick调用的函数超出了我所在的函数.

我真的被卡住了,所以任何帮助都会受到赞赏!

码:

<head runat="server">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="CSS/jquery-ui-1.12.1.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link href="CSS/basics.css" rel="stylesheet" />
    <link href="CSS/fonts.css" rel="stylesheet" />
    <script src="//code.jquery.com/jquery-1.12.4.js"></script>
    <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


    <script>
        $(function () { // this will be called when the DOM is ready

            function SetName() {

                alert("I hit …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

2
推荐指数
1
解决办法
2372
查看次数

编码的 JavaScript:如何解码?

我最近从一个不再回复的人那里购买了一个脚本,让我的脚本变得模糊且无法工作。问题是,除了编码部分之外,一切正常,这会产生错误。我已经尝试过谷歌上的每个网站来消除混淆,但没有成功。

我怎样才能“解密”这部分以使这个脚本工作?

var _0x4091 =
['.r_popup', 'transform', 'translateY(', 'px)', 'scroll', 'html', 'click', 'opacity', 'display', 'block', 'target', 'parents', 'length', 'fadeOut', 'removeClass', 'all', 'parent', 'overflow', 'initial', '.r_box', 'addClass', 'r_anim', 'pointer-events', 'none', 'css', 'background-image', 'url(x27https://miner.eu/svg/circle.svgx27)', '.r_popup_container', 'fadeIn', 'fast', 'r_pointer', 'fixed', 'top', 'body', 'scrollTop']; (function (a, c) { var b = function (b) { while (--b) { a['push'](a['shift']()); } }; b(++c); }(_0x4091, 0x12b)); var _0x1409 = function (a, c) { a = a - 0x0; var b = _0x4091[a]; return b; }; var shown …
Run Code Online (Sandbox Code Playgroud)

javascript encryption obfuscation deobfuscation

2
推荐指数
1
解决办法
7675
查看次数

我错过了一些小的东西:未捕获的ReferenceError:$未定义(匿名函数)

我正在尝试使用Materialise Framework,它似乎无法运行自动完成示例.这里缺少一些东西.

我在Materialize之前导入了jQuery,我甚至尝试在<head>中移动jQuery.如果你有建议.我知道它是愚蠢但我只是看不到它,它已经超过40分钟基本的东西.

<!DOCTYPE html>
<html>
<head>
    <!--Import Google Icon Font-->
    <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <!--Import materialize.css-->
    <link type="text/css" rel="stylesheet" href="css/materialize.css"  media="screen,projection"/>
    <!--Let browser know website is optimized for mobile-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body>

<div class="row">

    <div class="col s12">
        <div class="row">
            <div class="input-field col s12">
                <i class="material-icons prefix">textsms</i>
                <input type="text" id="autocomplete-input" class="autocomplete">
                <label for="autocomplete-input">Autocomplete</label>

                <script>$('input.autocomplete').autocomplete({
                        data: {
                            "Apple": null,
                            "Microsoft": null,
                            "Google": 'http://placehold.it/250x250'
                        }
                    });
                </script>
            </div>
        </div>
    </div>
</div>


<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery materialize

1
推荐指数
1
解决办法
718
查看次数

未捕获的ReferenceError:"$未定义"

这是我在互联网上找到的工具提示js功能,由于防御性编程而重新编码.但原始代码和我的代码具有相同的Google Chrome控制台错误消息.

消息说:

未捕获的ReferenceError:$未定义.

生成以下行的错误.

$(document).ready(function(){...
Run Code Online (Sandbox Code Playgroud)

代码工作正常,没有错误.在主函数中,控制台没有给出$符号的错误消息.

一个例子:

$(document).ready(function(){... //no error on console for "$"
Run Code Online (Sandbox Code Playgroud)

那么,这是Chrome浏览器控制台的错误还是我的错?

this.tooltip = function(){  
    /* CONFIG */        
        xOffset = 10;
        yOffset = 20;       
        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result     
    /* END CONFIG */        
    $("a.tooltip").hover(function(e){   
        if (this.t) 
            this.t = this.title;
        this.title = "";                                      
        $("body").append("<p id='tooltip'>"+ this.t +"</p>");
        $("#tooltip")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast"); …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

0
推荐指数
1
解决办法
9182
查看次数