jquery - Want to show image and disable submit button while ajax submit -


i posting image , text data working properly, during posting want show images , same time want disable post button, after form submission image should hidden , post button should enabled.

following code, here showing image , disabling post button not working.

<form id="own_message_post" action="ownmessages" method="post">        <textarea name="message" rows="4" cols="45" id="text_message" placeholder="update status"></textarea>          <img src="images/loader.gif" alt="posting" id="loading_img" style="visibility: hidden;">         <input id="fileupload" type="file" name="user_post_image" data-url="ownmessages">           <select name="msg_visibility">              <option value="public">public</option>              <option value="friends">friends</option>              <option value="me">me only</option>           </select>        <input type="submit" value="post" id="submit_form_button">         </form>  <script>          // wait dom loaded           $(document).ready(function() {           // bind 'myform' , provide simple callback function            $('#submit_form_button').click(function() {            var a= $('#text_message').val();            if(a=='' || a.length==0)              {                    $('#err').text("please post status");                     return false;                }            if(a.length<10)               {                    $('#err').text("minimum 10 characters required");                    return false;               }          });       $('#own_message_post').ajaxform(function(data) {                $("#loading_img").css("visibility", "visible");               $('#submit_form_button').attr("disabled", true);               $('#messages_and_pages').html(data);               $('#text_message').val("");               $('#fileupload').val("");               $('#submit_form_button').removeattr('disabled');               $("#loading_img").css("visibility", "hidden");            });       });  </script> 

change ajaxform part this:

    var options = {              beforesubmit:  function() {                           // code disable button , hide/show stuff     },              success: function(data) {                         // code enable button , show stuff     }};      $('#own_message_post').ajaxform(options); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -