How to set cache: false in jQuery.get call

前端 未结 7 519
天涯浪人
天涯浪人 2020-11-28 04:07

jQuery.get() is a shorthand for jQuery.ajax() with a get call. But when I set cache:false in the data of the .get() call

7条回答
  •  醉话见心
    2020-11-28 04:53

    Note that callback syntax is deprecated:

    Deprecation Notice

    The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback methods introduced in jQuery 1.5 are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    Here a modernized solution using the promise interface

    $.ajax({url: "...", cache: false}).done(function( data ) {
        // data contains result
    }).fail(function(err){
        // error
    });
    

提交回复
热议问题