Welcome Guest, Not a member yet? Register   Sign In
validation_errors not showing up with ajax
#6

[eluser]pickupman[/eluser]
I am using the same template library, and the way I use it by defining a ajax request variable.
Code:
//Global define for AJAX Requests
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

Now in my controller, when I finished parsing the results I use
Code:
if(IS_AJAX){
   //Page was loaded by ajax request
   $data['response'] = 'true';
   $data['message']  = $this->template->write_view('content','tpl.login_ajax.php',$data);
   echo json_encode($data); //Or have a ajax view to echo the json string
}else{
  $this->template->write_view('content','tpl.login.php', $data);
  $this->template->render(); //Echo out whole template
}

I use jQuery, and post login using .ajax(); I read the json response from the server to update the dom accordingly.


Messages In This Thread
validation_errors not showing up with ajax - by El Forum - 06-25-2010, 03:06 PM
validation_errors not showing up with ajax - by El Forum - 06-25-2010, 03:22 PM
validation_errors not showing up with ajax - by El Forum - 06-25-2010, 03:33 PM
validation_errors not showing up with ajax - by El Forum - 06-27-2010, 08:26 AM
validation_errors not showing up with ajax - by El Forum - 06-27-2010, 04:41 PM
validation_errors not showing up with ajax - by El Forum - 06-27-2010, 07:30 PM
validation_errors not showing up with ajax - by El Forum - 06-27-2010, 09:12 PM
validation_errors not showing up with ajax - by El Forum - 06-28-2010, 06:17 AM
validation_errors not showing up with ajax - by El Forum - 06-28-2010, 04:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB