2
我可以從標準http://傳遞錯誤,但我無法獲取$ errors值以在我的jquery調用中呈現(甚至傳遞)。任何人都知道我在這裏做錯了什麼?我已經在這裏約5個小時,並在我的臉上睡着了。感謝任何指導和批評。jquery getJSON()響應從cakephp控制器中爲空,但200次成功
我的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){
});
});
控制器動作:
function ajax_search_validate() {
if ($this->Plan->validates()) {
$this->Plan->set($this->data);
$errors = $this->Plan->invalidFields();
$this->set('errors', $errors);
}
}
視圖(可能是毫無意義張貼這一點,但什麼哎...):
<?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; ?>
螢火響應:
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