我在Symfony2工作
in detail.js
function saveForm() {
var url = $('#form_id').attr('action');
$.post(
url, $('#form_id').serialize(),
function(data){}
).success(function(){
alert("3");
}
).error(function(){
alert("4");
});
}
$(document).ready(function() {
$("#form_id").submit(saveForm);
});
在一个函数的控制器中
array('action' => $this->generateUrl('items_form_post2', array('id' => $id, 'redir' => 'items_detail')),
'attr' => array('id' => 'form_id'),));
web中的仍然是alert(4)
错误函数,但我不知道为什么
POST ......./app_dev.php/post-detail-form/173/items_detail
Accept */*
Accept-Encoding gzip, deflate
Accept-Language cs,en-us;q=0.7,en;q=0.3
Content-Length 344
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Cookie .....
Host ....
Referer .....
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0
X-Requested-With XMLHttpRequest
error ++++++++ it is console.log(textStatus);
e00bb3...il_1.js
(an empty string) ++++++++ it is console.log(errorThrown);
e00bb3...il_1.js
我没有看到任何像JSON
这样的回复-------------------------------- SOLUTION -------------- ----------------------------
function saveForm(event) {.....
event.preventDefault();