在CodeIgniter中的FancyBox中显示验证错误

I have a FancyBox in the home page which contains a registration form.

Validation is working fine.

Currently, I have to manually click on the FancyBox to see the error messages on that form.

Here's the code which reloads the page. But I want it to show the FancyBox as soon as the page loads. It is just a simple validation check.

if ($this->form_validation->run() == FALSE)
{
    $this->load->view('valform');
}
else
{
    $this->load->view('formsubmit');
}

So what I want is to show that FancyBox with validation errors.

Validation is working, as it is shown in the FancyBox; when the page reloads I have to manually click on that FancyBox to see the validation errors. Is there a way I can store it in a session and use that instead? If yes, how? Or how can I use ajax for this, and get validation errors to show on the FancyBox?

You can see the example below. Try to implement it with ajax and jquery.

public function ajax_()
{
  $this->form_validation->set_rules('par','name of something','required');

  if($this->form_validation->run()!=TRUE)
  {
    echo json_encode(array('result'=>'error','msg'=>validation_errors()));
  }
  else
  {
    echo json_encode(array('result'=>'success','msg'=>'success'));
  }
}