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 属性

posted @ 2017-03-13 15:34  巴别塔  阅读(930)  评论(0编辑  收藏  举报