• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] Delay in ajax response time

#1
Hi When I click on my approve button it sends a confirmation letter to the user and adds the members information to the main members table from the members temp table.

Every thing works fine but the email is causing about a 10 second delay for my ajax. Once the accout approve it refreshes the div but takes 10 second to refresh because of email library.

How to make that it faster.


Code:
<script type="text/javascript">
$(document).ready(function() {
    $(document).on('click', '#button-approve', function() {
        $.ajax({
            url : "<?php echo base_url(); ?>admin/members/dashboard/approve_member_login",
            type : "POST",
            dataType : "json",
            data : {
                "approve_member" : true,
                "member_temp_id" : $(this).attr('data-id')
            },
            success : function(data) {
                if (data['success'] = true)
                {
                    $('#new_member_approve').load(document.URL + ' #new_member_approve');
                }
            },
          
       });
    });
});        
</script>



PHP Code:
public function approve_member_login() {

    
$json = array();

    if (
$this->input->post('approve_member')) {

        
$newmembers_info $this->get_temp_members($this->input->post('member_temp_id'));

        
$config = Array(
            
'protocol' => 'smtp',
            
'smtp_host' => 'ssl://smtp.googlemail.com',
            
'smtp_port' => 465,
            
'smtp_user' => 'email',
            
'smtp_pass' => 'password',
            
'mailtype'  => 'html'
            
'charset'   => 'iso-8859-1'
        
);


        
$this->load->library('email'$config);
        
$this->email->set_newline("\r\n");

        
$this->email->from('myemail''Admin');
        
$this->email->to($newmembers_info['email']);
        
$this->email->subject('Account Approved');
        
$this->email->message('Hi, Just to confirm that your account has now been approved at Admin Area');

        
$this->email->send();

        
$insert_data = array(
            
'username' => $newmembers_info['username'],
            
'email' => $newmembers_info['email'],
            
'password' => $newmembers_info['password'],
            
'firstname' => $newmembers_info['firstname'],
            
'lastname' => $newmembers_info['lastname'],
            
'status' => '1'
        
);

        
$this->db->set($insert_data);
        
$this->db->insert('members');

        
$this->db->where('member_id'$this->input->post('member_temp_id'));
        
$this->db->delete('members_temp');


        
$json['success'] = true;

    }

 
   $this->output->set_content_type('application/json');
 
   $this->output->set_output(json_encode($json));


There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[solved] Delay in ajax response time - by wolfgang1983 - 10-22-2017, 02:48 AM
RE: Delay in ajax response time - by InsiteFX - 10-22-2017, 03:22 AM
RE: Delay in ajax response time - by wolfgang1983 - 10-22-2017, 09:57 PM
RE: Delay in ajax response time - by wolfgang1983 - 10-22-2017, 04:01 PM
RE: Delay in ajax response time - by skunkbad - 10-22-2017, 11:02 PM
RE: Delay in ajax response time - by wolfgang1983 - 10-22-2017, 11:28 PM
RE: Delay in ajax response time - by skunkbad - 10-23-2017, 04:32 PM
RE: Delay in ajax response time - by wolfgang1983 - 10-24-2017, 03:50 AM
RE: Delay in ajax response time - by InsiteFX - 10-23-2017, 08:52 AM
RE: Delay in ajax response time - by wolfgang1983 - 10-23-2017, 11:50 AM
RE: Delay in ajax response time - by wolfgang1983 - 10-24-2017, 03:52 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.