weixin_33716154 2018-12-11 21:46 采纳率: 0%
浏览 8

Ajax jQuery中的标题

why we set headers in ajax.whats the purpose of header in ajax.I dont know whats the header do.A little bit confusion arise when i analyse code.Just tell whats the header do or why we use.

$.ajax({
            type:       "GET",
            cache:      false,
            url:        $(this).data("url")+'?param='+status,
            dataType:   "json",
            headers:    { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
            success: function(res) {
                if (res.flag == true) {
                    toastr["success"](res.msg, "Completed!");
                    if(res.action == 'reload') {
                        window.location.reload();
                    }else{
                        $("." + remvove).remove();
                    }
                }
            }
        });

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?