Reputation: 1
I need to disalble submit button after ajax forever! But when I reload the page submit button is active(
function submitConfirmAjaxList(e){
var url = "<?php echo $this->getUrl('wedding/gifts/confirmList') ?>";
var getTransferId = '<?php echo $checkTransferId?>';
var getCurrentCustomerId = '<?php echo $getCurrentCustomerId?>';
var confirmResponse = 1;
var disalleButton = $('confirmButton').setAttribute('disabled', 'disabled');
new Ajax.Request(url, {
method:'post',
parameters: {
getTransferId : getTransferId,
getCurrentCustomerId : getCurrentCustomerId,
confirmResponse : confirmResponse
},
requestHeaders: {Accept: 'application/json'},
onSuccess: function(transport) {
location.reload();
e.disable();
}
});
}
__('Сonfirm the list')?>" class="button" onclick="submitConfirmAjaxList(this)">__('confirm the list')?>
Upvotes: 0
Views: 636
Reputation: 167
Use this in AJAX Success:
$(".class").attr('disabled','disabled');
Upvotes: 0
Reputation: 208
After sucess, put some value in cookie, validaty of cookie should be till current session, on page load (may be document.ready) check if cookie value is specific to which you stored then disable the button with jquery.
Upvotes: 0
Reputation: 840
You could easily accomplish that if you would delete your location.reload();
. The idea of ajax is the asynch call, which is executed and processed without reloading the entire page. That said you can just put $('#confirmButton').attr('disabled', 'disabled');
in your onSuccess: function(transport) {}
method and you should be fine
Upvotes: 1
Reputation: 943564
If you reload the page then you have a new page which doesn't maintain state from any previous changes you made with JavaScript.
You need to store something on the server (e.g. in session data or the user's account data in the database) that indicates the submit button should be disabled.
Then your server side code should include a disabled
attribute in the button when the page loads.
Upvotes: 0