Reputation: 34158
I have post form with submit button before submit i need to call c# code behind get hash and then change value of hidden input.
Code behind is calling but problem is that while i get result from c# code form is submiting how i can first get result and then submit form?
Jquery:
$('#pay_form').submit(function(){
GetHash();
});
function GetHash()
{
var amount = $('#txtInAmount').val();
$.ajax({
url: '/Transactions/GetOrderCodeHah',
type: 'POST',
dataType: 'json',
data: { Amount: amount },
success: function (result){
$('#txtOrderCode').val('231321321321321321');
$('#txtCheck').val(result.hash);
},
error: function(){
return false;
}
});
}
Upvotes: 2
Views: 1231
Reputation: 887453
You need to return false;
from the submit()
handler, then explicitly submit()
the form in the AJAX callback.
Upvotes: 2