1 回答

TA貢獻1847條經(jīng)驗 獲得超11個贊
下面給你一個登錄的例子,流程:ajax提交后臺-訪問數(shù)據(jù)庫-返回數(shù)據(jù)-登錄成功
1、Html代碼
1 2 3 | <input type="text" id="User"> <input type="text" id="Psd"> <input type="button" onclick="Login();" id="登錄"> |
2、js代碼
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | funcation Login(){ $.ajax({ type: "post", contentType: "application/json", url: "../Backstage/AdminService.asmx/GetAdminList",//請求后臺方法 data: JSON.stringify({ Name: user,Password:psd}), success: function (result) { //判斷result.d的值; }, error: function (response) { var r = jQuery.parseJSON(response.responseText); alert("Message: " + r.Message); } }) } |
3、一般處理程序
1 2 3 4 5 6 | [WebMethod] public bool GetAdminList(string Name;string Password) { //訪問數(shù)據(jù)庫 //成功返回true,失敗返回False; } |
- 1 回答
- 0 關(guān)注
- 564 瀏覽
添加回答
舉報