Welcome Guest, Not a member yet? Register   Sign In
xajax + codeigniter
#1

[eluser]Harishkulkarni[/eluser]
Hi guys,

I started learning CI from last 3-4 days.
i am using xajax with CI for checking username already exists in DB in registration page.
I got the result for that.But....
Now i want to show loading ring(when response takes some time to come,that time i want to show a rotating ring image).But i am not getting how to check the status of response using xajax.I googled lot, didnt get any thing on status checking.


Below is my controller for user.Please let me know how to check the status of reponse.
thanks in advance for any kind of help.

<?php
class User extends Controller
{

function User()
{
parent::Controller();
$this->load->library('auth');
$this->load->library('xajax');
$this->validation->set_error_delimiters('<div class="error">', '</div>');
$this->xajax->registerFunction(array('fn_checkuser',&$this,'fn_checkuser'));
$this->xajax->processRequest();

}



function fn_checkuser($arr)
{
$objectResponse = new xajaxResponse();

if($this->auth->username_exists($arr['username']))
{
$objectResponse->assign("err_name","innerHTML","Username already exist!!!!");
}
else
{
$objectResponse->assign("err_name","innerHTML","You can use this username");
}

return $objectResponse;
}



function register()
{

$this->load->library('validation');
$rules['username'] = 'required|xss_clean';
$rules['password'] = 'required|matches[passconf]';
$rules['passconf'] = 'required';

$this->validation->set_rules($rules);

$fields['passconf'] = 'Confirm password';
$this->validation->set_fields($fields);

if ($this->validation->run() == FALSE)
{
//$this->load->view('login');
//redirect('user/login');
}
else
{

$username = $this->input->post('username');
$password = $this->input->post('password');

if($this->auth->username_exists($username) == TRUE)
{
$this->session->set_flashdata('msg', 'User name already exists.please try another one');
redirect('user/register');
}

if($this->input->post('submit'))
{
if($this->auth->create($username,$password))
{
//'Registered';
$this->session->set_flashdata('msg', 'Congradulataions..!!Successfully registered');
redirect('user');
}
else
{
//failed
$this->session->set_flashdata('msg', 'Registaraton failed');
redirect('user/register');
}
}

}
//ASSIGN JAVASCRIPT LIBRARY TO VIEW
$data['xajax_js'] = $this->xajax->getJavascript(base_url());

$this->load->view('register',$data);
}




}

?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB