function submitpost(id) {
$('#tiers-form'+id).on('submit', function (e) {
var form = $('#tiers-form'+id);
$('#success'+id).fadeIn();
$('#success'+id).html('<div class="loader"></div>');
$.ajax({
type: 'POST',
url: '<?php echo yii::app()->createUrl('toshidesk/wallet/tips'); ?>',
data: $('#tiers-form'+id).serialize(),
success: function (data) {
var obj = jQuery.parseJSON(data);
console.log(obj);
if (obj !== null && typeof (obj.reward) != "undefined") {
alert(obj.reward);
$('#success'+id).fadeOut(500);
} else if (typeof (obj.error) != "undefined") {
alert(obj.error);
$('#success'+id).fadeOut(500);
} else {
$('#price'+id).val('');
$('#success'+id).html(data);
$('#success'+id).attr("class", "alert alert-success message");
$('.message').fadeOut(9000);
}
}
});
e.preventDefault();
});
}
i have multiple form in one page.form will open in bootstrap model.when i submit form without fill value error occur value is not set. first time (or on first submit) there will send only one ajax request while on second click there will submit two ajax request.
Aucun commentaire:
Enregistrer un commentaire