admin管理员组

文章数量:1400477

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="">

本文标签: