zoukankan      html  css  js  c++  java
  • ajax请求头添加参数

    在请求ajax时 ,有时后台要求在请求头里边上参数 ,这种情况下一般都是在原生APP项目当中,因为要在登录状态下才,所有要传token和登录id,

    var token = localStorage.getItem('token')||'';
    var identity = localStorage.getItem('identity')||''; 
    $.ajax({
    	type: params.type || 'post',
    	url: dev.APIURL + params.url || null,
    	dataType:'json',
    	data: params.data || null,
    	headers: {
    	  'token':token,
    	   'identity':identity,
    	   'Content-Type': 'application/x-www-form-urlencoded'
    	},
    	success: function (res) {
    	    vue.$indicator.close()
    	    if(res.code != 200 && res.msg){
    		vue.$toast(res.msg);
    	    }
    	    resolve(res)
    	},
    	error: function (err) {
    	   reject(err)
         }
    });
    

      

      

  • 相关阅读:
    Spring MVC 复习笔记03
    Spring MVC 复习笔记02
    CSS之选择器
    Filedset
    Label标签
    Table标签
    列表标签
    CSS之img标签
    CSS之a标签锚点
    CSS之checkbox&radio&textarea&select
  • 原文地址:https://www.cnblogs.com/liubingyjui/p/12596783.html
Copyright © 2011-2022 走看看