以下代码用于从数据库中获取特定用户数据
并显示在Readable Textbox's
我有另一套Textbox's
用于insert data into database
,在插入数据后我想获取该数据并显示在Readable Textbox
到txtuser Textbox
。
// this jquery code execute when we click on `Get Button`
$('#btnGet').click(function(){
var txtuser = $('#txtuser').val();
$.ajax({
contentType: 'application/json; charset=utf-8',
url: 'WebForm1.aspx/GetUser',
data: JSON.stringify({ username: txtuser}),
dataType: 'json',
method: 'post',
success: function (data) { $('#txtfirstname').val(data.d.Firstname);
$('#txtlastname').val(data.d.Lastname);
$('#txtemail').val(data.d.Email);
},
error: function (result) {
alert('Error');
}
});
return false;
});
// this jquery code execute when we click on `Submit Button`
$('#btnSubmit').click(function(){
var txtuser = $('#txtuser').val();
var txtfirstname = $('#txtfirstname').val();
var txtlastname = $('#txtlastname').val();
var txtemail = $('#txtemail').val();
$.ajax({
contentType: 'application/json; charset=utf-8',
url: 'WebForm1.aspx/InsertUser',
data: JSON.stringify({ username: txtuser, firstname:txtfirstname, lastname : txtlastname, email:txtemail}),
dataType: 'json',
method: 'post',
success: function (data) { $('#txtfirstname').val(data.d.Firstname);
$('#txtlastname').val(data.d.Lastname);
$('#txtemail').val(data.d.Email);
},
error: function (result) {
alert('Error');
}
});
return false;
});
如何实现这一任何帮助