PDA

View Full Version : سوال: انتقال به دیتابیس به وسیله ajax و به صورت async



moferferi
دوشنبه 28 مرداد 1392, 15:09 عصر
سلام
من از این روش واسه درج اطلاعات در دیتابیس استفاده میکنم
<script type="text/javascript">
$(document).ready(function () {
$('#Button1').click(function () {
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: 'InsertByWebMethod.aspx/InsertMethod',
data: "{'Name':'" + document.getElementById('txtUserName').value + "', 'Email':'" + document.getElementById('txtEmail').value + "'}",
async: false,
success: function (response) {
$('#txtUserName').val('');
$('#txtEmail').val('');
alert("Record Has been Saved in Database");
},
error: function ()
{ console.log('there is some error'); }
});
});
});
</script>

اگه بیایم و async: false به true تغییر بدیم ،دیگه کار نمیکنه
ایا برای ارسال به روش async باید روش دیگه ای را استفاده کنیم؟