javascript - jQuery.Deferred exception: $(...).error is not a function, TypeError $(...).error is not a function - Stack Overflo

I've searched alot to find the answer, but on every page or every question the problem is either t

I've searched alot to find the answer, but on every page or every question the problem is either the Person didnt include the jQuery files proberly or they were naming something wrong. I tried to use different jQuery CDNs, but obviously the same error came. I even deleted my whole script to look if there is a conflict with the code. Strange thing is, only the .error() handler gets this error. Every other handler works fine. If i call .error() on an other element, it spits out the same error.

HTML:

<img class="prev_img" src="img/no_image.png" alt="Vorschau Bild" width="250px" height="160px">

JS

<script
  src=".4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous"></script>


<script type="text/javascript"> 
    $(document).ready(function(){
        $("img").error(function(){
            console.log("Error");
        });
    });
</script>

I really don't know what the Problem could be. I restarted my XAMPP multiple times in Hope its messing something up with the file inclution. But it seems that everything works fine.

I'm glad if i could get some help.

Greetings

EDIT:

I've tried using

$(document).ready(function(){
        $("img").on("error", function(){
            console.log("Error");
        });
    });

but even though in the console i get a GET 404 not found error, the error handler doesnt do anything.

I've searched alot to find the answer, but on every page or every question the problem is either the Person didnt include the jQuery files proberly or they were naming something wrong. I tried to use different jQuery CDNs, but obviously the same error came. I even deleted my whole script to look if there is a conflict with the code. Strange thing is, only the .error() handler gets this error. Every other handler works fine. If i call .error() on an other element, it spits out the same error.

HTML:

<img class="prev_img" src="img/no_image.png" alt="Vorschau Bild" width="250px" height="160px">

JS

<script
  src="https://code.jquery./jquery-3.4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous"></script>


<script type="text/javascript"> 
    $(document).ready(function(){
        $("img").error(function(){
            console.log("Error");
        });
    });
</script>

I really don't know what the Problem could be. I restarted my XAMPP multiple times in Hope its messing something up with the file inclution. But it seems that everything works fine.

I'm glad if i could get some help.

Greetings

EDIT:

I've tried using

$(document).ready(function(){
        $("img").on("error", function(){
            console.log("Error");
        });
    });

but even though in the console i get a GET 404 not found error, the error handler doesnt do anything.

Share Improve this question edited Dec 16, 2019 at 15:44 Niggo123999 asked Dec 16, 2019 at 15:35 Niggo123999Niggo123999 371 silver badge4 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 6

Per the documentation, .error() was deprecated in 1.8 and removed in 3.0.

Use .on("error", function() { ... }) instead.

$("img").on("error", function() {
  console.log("Error");
});
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img src="">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744238776a4564602.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信