[javascript] event.returnValue is deprecated. Please use the standard event.preventDefault() instead

I have this script:

<script>
$(document).ready(function () {
    $("#changeResumeStatus").click(function () {
        $.get("{% url 'main:changeResumeStatus' %}", function (data) {
            if (data['message'] == 'hidden') {
                $("#resumeStatus").text("??????");
            } else {
                $("#resumeStatus").text("????????????");
            }
        }, "json");
    });
});
</script>

I receive the following error in my Google Chrome console:

event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

I am using jQuery v1.10.2 and #changeResumeStatus is a <span>.

What's wrong with my script?

This question is related to javascript jquery ajax

The answer is


If you using Bootstrap:

The current version of Bootstrap (3.0.2) (with jQuery 1.10.2 & Chrome) seems to generate this warning as well.

(It does so on Twitter too, BTW.)

Update

The current version of Bootstrap (3.1.0) no longer seems to generate this warning.


That's your jQuery API problem, not your script. There is not much to worry about.


I found that using the latest version will fix this problem:
http://code.jquery.com/jquery-git.js


I saw this warning on many websites. Also, I saw that YUI 3 library also gives the same warning. It's a warning generated from the library (whether is it jQuery or YUI).


Just for other's reference, I just received this and found it was due to AngularJS. It's for backwards compatibility:

if (!event.preventDefault) {
    event.preventDefault = function() {
        event.returnValue = false; //ie
    };
}

This is a warning related to the fact that most JavaScript frameworks (jQuery, Angular, YUI, Bootstrap...) offer backward support for old-nasty-most-hated Internet Explorer starting from IE8 down to IE6 :/

One day that backward compatibility support will be dropped (for IE8/7/6 since IE9 deals with it), and you will no more see this warning (and other IEish bugs)..

It's a question of time (now IE8 has 10% worldwide share, once it reaches 1% it is DEAD), meanwhile, just ignore the warning and stay zen :)


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to jquery

How to make a variable accessible outside a function? Jquery assiging class to th in a table Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Getting all files in directory with ajax Bootstrap 4 multiselect dropdown Cross-Origin Read Blocking (CORB) bootstrap 4 file input doesn't show the file name Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource how to remove json object key and value.?

Examples related to ajax

Getting all files in directory with ajax Cross-Origin Read Blocking (CORB) Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource Fetch API request timeout? How do I post form data with fetch api? Ajax LARAVEL 419 POST error Laravel 5.5 ajax call 419 (unknown status) How to allow CORS in react.js? Angular 2: How to access an HTTP response body? How to post a file from a form with Axios