javascript - How to enable and disable Twitter Bootstrap Button? -
i trying achieve scenario of disabling button on clicking it, , enabling again after ajax request has completed successfully.
the below snippet of code.
form
<button id="btnsubmit" type="submit" class="btn btn-warning btn-lg">submit!</button>
javascript
$('#resform').validate({ // disable submit button $('#btnsubmit').prop('disabled', true); submithandler: function(form) { $.ajax({ ..... typical ajax stuff ..... success: function(data) { alert(data); $('success').html(data); // enable reserve button again $('#btnsubmit').prop('disabled', false); }, error: function (jqxhr, textstatus, errorthrown) { // console.log(jqxhr); } }); } });
it doesn't work. , checking console on chrome tells me uncaught syntaxerror: unexpected token (
. feels it's stupid mistake somewhere , can't figure out. have read prop
meant jquery 1.6.1 , later , on 1.8.3.
$('#resform').validate({ submithandler: function(form) { // disable submit button $('#btnsubmit').prop('disabled', true); $.ajax({ ..... typical ajax stuff ..... success: function(data) { alert(data); $('success').html(data); // enable reserve button again $('#btnsubmit').prop('disabled', false); }, error: function (jqxhr, textstatus, errorthrown) { // console.log(jqxhr); } }); } });
try this
Comments
Post a Comment