beforeSend in $.ajaxSetup + beforeSend in $.ajax

前端 未结 1 1529
名媛妹妹
名媛妹妹 2021-01-14 16:52

To solve the CSRF problem, I use a client-side setup for Ajax:

$.ajaxSetup({
    beforeSend: function(xhr, settings) {
        function getCookie(name) {
            


        
相关标签:
1条回答
  • 2021-01-14 17:09

    Use $(document).ajaxSend(function(ev, jqhr, settings) { ... }) instead of .ajaxSetup.

    As you said .ajaxSetup defines a default handler which then can be overriden. With .ajaxSend you can register multiple handlers to fire before an ajax request is sent. Works fine with custom beforeSend handler.

    0 讨论(0)
提交回复
热议问题