Passing Custom Headers to Ajax request on Select2

后端 未结 5 2095
庸人自扰
庸人自扰 2021-01-11 15:01

We are trying to implement Ajax Remote data loading in Select2:-

 $scope.configPartSelect2 =  {
        minimumInputLength: 3,
        ajax: {
            ur         


        
5条回答
  •  日久生厌
    2021-01-11 15:22

    Taken from select2's demo page:

    Select2 will pass any options in the ajax object to jQuery's $.ajax function, or the transport function you specify.

    Using JQuery 2+, I was able to successfully set OAuth 2.0 and Content-Type headers.

    ajax: {
        headers: {
            "Authorization" : "Bearer "+Cookies.get('accessToken'),
            "Content-Type" : "application/json",
        },
    }
    

提交回复
热议问题