I can pass my errors from standard http://, but I cannot get the $errors values to render (or even pass) in my jquery call. Anyone know what I am doing wrong here? I've been at this for about 5 hours and falling asleep on my face.. Thanks for any guidance and critique.
My jQuery:
$j("#applicant_age").focusin(function(){
$j(this).css("background-color","#FFFFCC");
});
$j("#applicant_age").focusout(function(){
$j(this).css("background-color","#ffffff");
$j.getJSON('<?php echo $this->Html->url(array('controller'=>'plans', 'action'=>'ajax_search_validate'))?>', function(json){
});
});
Controller Action:
function ajax_search_validate() {
if ($this->Plan->validates()) {
$this->Plan->set($this->data);
$errors = $this->Plan->invalidFields();
$this->set('errors', $errors);
}
}
View (probably pointless to post this but what the hey...):
<?php
foreach ($errors as $error) :
?>
<p id="errorStyle" style="padding: 10px; background-color: #FF3333; color: #ffffff; margin: 0px 0px 10px 0px; "><?php echo $error; ?></p>
<?php endforeach; ?>
FireBug response:
ResponseHeaders
Date Wed, 18 May 2011 09:28:51 GMT
X-Powered-By PHP/5.2.6-1+lenny10
P3P CP="N..."
Connection Keep-Alive
Content-Length 0
Server Apache/2.2.9 .....
Content-Type text/html
Keep-Alive timeout=15, max=100
RequestHeaders
Accept application/json, text/javascript, */*; q=0.01
X-Requested-With XMLHttpRequest