on-internet
← Community

Submit form with AJAX and set input field to readonly

Stack Overflow ·

I have a problem with submitting form with AJAX, print the response string under the form and set the input to readonly. My code: $('#save').click( function(){ var form_data ={ name: $('#name').val(), ajax:'1' }; $.ajax({ url:"page.php", type: 'POST', data: form_data, success: function(data){ $('#form_message').html(data); } }); $('#name').toggleClass('bgcolored'); $('#save').addAttr('readonly'); $('#save').toggleClass("invisible"); return false; } If I delete the row $('#save').addAttr('readonly'); the script works: it send values, catch the response and print it into the div form_message and

Comments

Sign in or sign up to comment and upvote.

No comments yet.