Ajax 請求 - 登入網站

來源:互聯網
上載者:User

標籤:style   class   blog   code   java   http   

JavaScript 中的ajax提交請求

$.ajax({// 提交地址        url: "",    // 提交的資料        data: { key1: value1, key2: value2, key3: value3, key4: value4 },// 提交前事件        beforeSend: function () {            login.hide();            showInfo.html(loginInfo);        },// 提交方式        type: "POST",// 提交的資料類型        dataType: "json",// 提交成功後事件        success: function (result) {            if (result.State.toString() == "success" && result.IsLogin.toString() == "1") {                showInfo.addInfoMsg("登入成功!正在跳轉. . .");                window.location.href = "/Default.aspx";            }            else {                login.show();                showInfo.addShowMsg(result.exMsg.toString());            }        },// 提交錯誤時間        error: function (httpRequest, textStatus, errorThrown) {            showInfo.addShowMsg("系統出錯,請重新登入!");            login.show();        }    });

返回的資料格式:

// 返回的資料格式 一下 var returnInfo = "\"State\":\"{0}\",\"IsLogin\":\"{1}\",\"exMsg\":\"{2}\"";context.Response.Write("{" + String.Format(returnInfo, "success", "1", "登入成功!") + "}");context.Response.Write("{" + String.Format(returnInfo, "fail", "0", "使用者名稱不可為空") + "}");context.Response.Write("{" + String.Format(returnInfo, "fail", "0", "密碼不可為空") + "}");context.Response.Write("{" + String.Format(returnInfo, "fail", "0", "您沒有登入系統的許可權,請聯絡貴公司管理員.") + "}");context.Response.Write("{" + String.Format(returnInfo, "fail", "0", "非法登陸," + ex.Message + "}"));

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.