ajax 功能正在开发中http://mysite/playlist-edit/3
Javascript:
$("#applySort").click(function(){
var list = $("#sortable").sortable('toArray');
$.post({
type: 'POST',
url: " {{ path('save_sorting', { 'id' : customer.id}) }} ",
data: { "list" : JSON.stringify(list) },
success: function(data) {
alert("success");
}
});
return false;
});
路线:
save_sorting:
pattern: /save-sorting/{id}
defaults: { _controller: SomeApiBundle:Customer:applySorting}
requirements:
_method: POST
控制器动作(空):
private function applySortingAction($id){
}
错误:
POST http://mysite/playlist-edit/%5Bobject%20Object%5D
500 内部服务器错误
正如您在 javascript 代码中看到的,http://mysite/playlist-edit/%5Bobject%20Object%5D
实际上不是 javascript 中的 url,它应该是http://mysite/save-sorting/3
.
Jquery 似乎调用了错误的 url。
Request-Header
Accept */*
Accept-Encoding gzip, deflate
Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Connection keep-alive
Cookie PHPSESSID=rkdre4frkoidgo3n1hsi4th7v5
DNT 1
Host gartenfernsehen
Referer http://mysite/playlist-edit/3
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
X-Requested-With XMLHttpRequest
Response-Header
Connection close
Content-Length 0
Content-Type text/html
Date Mon, 25 Jun 2012 06:21:07 GMT
Server Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By PHP/5.3.8
任何想法为什么我会收到此错误?我注意到这http://mysite/playlist-edit/%5Bobject%20Object%5D
实际上是错误的,但我不知道它是如何创建的。