It may take a long time to complete the call.php and get the return value, how can I change the submit button's value to "Processing … " while the call.php is being executed?
Submit button with id "submit_btn", there is no change to the script
$('#submit_btn').val('Processing …')
AJAX code
$(document).ready(function(){
$('#form1').submit(function(e) {
e.preventDefault();
$('#submit_btn').val('Processing ...');
$.ajax({
cache: false,
type: "POST",
dataType: "json",
data: $('#form1').serialize(),
url: $('#form1').attr('action'),
complete: function (HttpRequest, textStatus) {
$('#submit_btn').val('Create');
}});
return false;
});
});
HTML
<form action="call.php" method="POST" id="form1" name="form1">
<input type="text" name="campname" id="campname">
<textarea id="longdesc" name="longdesc"></textarea>
<input type="text" name="vercode" id="vercode" />
<input type="submit" value="Create" id="submit_btn" />
</form>
$(document).ready(function(){
$('#submit_btn').click(function(e) {
e.preventDefault();
$(this).val('Processing ...'); // this did the trices
$.ajax({
cache: false,
type: "POST",
dataType: "json",
data: $('#form1').serialize(),
url: $('#form1').attr('action'),
complete: function (HttpRequest, textStatus) {
$('#submit_btn').val('Create');
}});
return false;
});
});
For my this was the one that worked in a page with many forms with the same name and id
$(this).find("#submit").val("Saved");