ajax方法携带授权标识
$.ajax({ type: "post", url: "/api/login", data: { username: getusername, password: getuserpwd,client:getclient }, dataType: "json", xhrFields: { withCredentials: true }, //contentType: 'application/json; charset=utf-8', //客户端(浏览器)解码方式 success: function (data) { if (data.success) { $("form").submit(); } else { $("#lblerror").text(data.message); $("#btnSubmit_login").removeClass("disabled").val("登 录"); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); } });
方法中添加
xhrFields 属性