i am registering users via ajax, user is inserted into the database but my loader continue to show loading and is no hiding furthermore i put an alert to view the result but it is also not shown 
so where i am doing wrong please help me.
here is my view 

```
 <tr>
    <td style="width: 25%;"><p>Name</p>
    <input type="text" name="name" id="name_r" 
    placeholder="Enter name" required=""/>
    </td> 

    <td style="width: 25%;"><p>username</p>
    <input type="text" name="username" id="uname" 
    placeholder="Enter username" required=""/>  
    </td>   

  </tr> 

```

my script is

```
 $(document).ready(function(){
  $("#register_staff").click(function(){
  var name = $("#name_r").val();
  var username = $("#uname").val();

  if (name && username) {
  $('#loader_register').show();        
    $.ajax(
            {
              type: "POST",
              url:"<?php echo 
           base_url('register_management_staff')? 
           >",
              data:{name:name,username:username},
              success: function(result){
                  alert(result);
              $('#loader_register').hide();
              $('#name_r').val("");

              $('#result_register').html(result);
              }
            }
          );
    }
    else{  
 document.getElementById
('result_register').innerHTML='<font color=red>
Please fill all fields.</font>';

    }

  });
}); 

```

my controller is

```
public function register_management_staff()
{  
$post['name']= $_REQUEST['name'];
$post['username']= $_REQUEST['username'];

$result =  $this->managementmodel
->register_management_staff($post);
if($result == 1){
   echo '<font color=green>Congrats! Successfully 
 Register.</font>';
         }
  else{
  echo '<font color=red>Please enter correct data 
  and check availability.</font>';
         } 
  }

```

my model is

```
public function register_management_staff($post)
{

 $this->db->insert('management_login',$post);
       return 1;

}

```