Home On Mobile devices setTimeout() causing error
Reply: 0

On Mobile devices setTimeout() causing error

user2704 Published in April 22, 2018, 4:57 am

I am working on form, it is properly showing that "form is submitted" on desktop, and message hides after some seconds.

But on mobile it is not showing any message for submitted form.

Here is My code.


<p id="password_response_msgs" style="margin-left:40px; color:#F00"></p>
    <div class="row">
       <div class="col-sm-6 form-group">
          <form name="password_form" method="post">
             <label class="sr-only" for="userFirstName">Password</label>
             <input type="password" class="form-control" name="password" id="user_password" placeholder="password" value="<?php echo $row['password']?>">
       <div class="col-sm-6 form-group">
              <label class="sr-only" for="userLastName">Confirm Password</label>
              <input type="password" class="form-control" name="confirm_password" id="user_confirm_password" placeholder="Confirm Password" value="">
   <div class="row">
       <div class="col-md-6">
          <a class="btn btn-block btn-primary" onClick="updatepassword();" style="color:#FFF">Update Password</a>

Javascript & Ajax

function updatepassword(){
     var user_password = document.getElementById('user_password').value;
     var user_confirm_password = document.getElementById('user_confirm_password').value;
       document.getElementById('password_response_msgs').innerHTML = 'Please Enter Password';
     }else if(user_confirm_password==''){
        document.getElementById('password_response_msgs').innerHTML = 'Please Enter Confirm Passowrd';
              url: "<?php echo BASE_URL;?>ajax/save-profile.php",
              data:{command:'updatepassword',password:user_password,user_confirm_password:user_confirm_password,user_id:<?php echo $user_id;?>},
              cache: false,
              success: function(res) {
                    document.getElementById('password_response_msgs').innerHTML = res;

And i hides the message after some seconds in this way. This works on desktop, but not mobile devices. But if i delete the below code then message also shows on mobile devices.

  setTimeout(function() {
  }, 10000);

why it is not working on mobile?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31613 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO