sinat_34498624
java是最好的语言
2016-08-02 06:35
采纳率: 100%
浏览 3.3k
已采纳

jquery datatable中的sAjaxSource问题

最近刚接触datatable对此不太熟悉,我知道sAjaxSource后面放url,但是我要请求的url有表头,我不知道怎么加
httprequest = new XMLHttpRequest();
httprequest.open("GET",
"http://123.563:8088/kiunionSer/ws/v1.0/vehicleBaseInfo/searchByEnterprise?enterpriseId=1&start=0&limit=30");
httprequest.setRequestHeader("Authorin", "MDphZG1pbg");
上面是我用ajxa请求的方法,请问在datatable中怎么加("Authorin", "MDphZG1pbg");这两个

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • showbo
    已采纳

    ajax是jquery发送的,调用ajaxSetup配置其他请求头即可

           jQuery.ajaxSetup({ headers: { Authorin: 'MDphZG1pbg' } });//////////////////////
                $(document).ready(function() {
                    var oTable = $('#example').dataTable( {
                        "bProcessing": true,
                        //"bServerSide": true,
                        "sAjaxSource": "sources/arrays.txt" 
                    } );
                } );
    
    点赞 评论
  • feng1790291543
    鱼弦 2016-08-02 06:46

    写法例子如:
    var method = "get";
    var url = "test.php";
    var async = true;
    var data = "username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password)
    xmlHttp.open(method, url, async);
    //设置回调函数,接收服务器端的信息以进行处理
    xmlHttp.onreadystatechange = getServerInfo;

    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-Length", data.length);
    xmlHttp.send(data);

    知道问题在哪里把?

    点赞 评论
  • devmiao
    devmiao 2016-08-02 06:47
    点赞 评论

相关推荐