Difference between $.ajax(); and $.ajaxSetup();

后端 未结 5 1452
温柔的废话
温柔的废话 2020-12-01 04:18

What is the difference between $.ajax(); and $.ajaxSetup(); in jQuery as in:

$.ajax({
    cache:false
});

and

5条回答
  •  一生所求
    2020-12-01 04:33

    The following will prevent all future AJAX requests from being cached, regardless of which jQuery method you use ($.get, $.ajax, etc.)

    $(document).ready(function() {
      $.ajaxSetup({ cache: false });
    });
    

    you should use $.ajax, which will allow you to turn caching off for that instance:

    $.ajax({url: "myurl", success: myCallback, cache: false});
    

提交回复
热议问题