|
|
|
ขอตัวอย่างการใช้ Ajax ใน ASP.NET หน่อยค่ะ จะเอามาดัดแปลงใช้ในหน้า Login ค่ะ |
|
|
|
|
|
|
|
Ajax Sample Tutorials
|
|
|
|
|
Date :
2010-12-08 15:34:19 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าหน้า Login เอา jquery เข้าไปใช้ด้วยก็ดีนะ
นี่ตัวอย่าง
Code (JavaScript)
function Authentication() {
ShowSuccessed();
username = $('#username')[0].value;
password = $('#password')[0].value;
$("#user-input").hide();
$.ajax({
type: "POST",
dataType: "json",
url: "IPadQuestionnaireService.asmx/Authentication",
data: '{"username": "' + username + '", "password":"' + password + '"}',
contentType: "application/json; charset=utf-8",
success: function (message) {
if (message == 'NOT-FOUND') {
ShowFailed();
}
else {
$(this).delay(30000);
var item = message.split('|')
$.cookie("fullname", item[0]);
$.cookie("sale-id", item[3]);
$.cookie("sale-code", username);
$.cookie("p-code", $('#password')[0].value);
if ($("#lang1")[0].checked)
$.cookie("default-language", $("#lang1")[0].value);
else
$.cookie("default-language", $("#lang2")[0].value);
$.cookie("accessibleProjcet", message.split('|')[2]); // item 0 is fullname, item 1 is user code
window.location = "select-project.html";
}
},
error: function (xhr, msg) {
$("#au-success").hide();
ShowFailed();
}
});
}
|
|
|
|
|
Date :
2010-12-08 16:12:41 |
By :
nooknoname |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|