我想做jQuery删除Ajax,但得到HTTP错误400. 我正在寻找,我看到有一些问题与删除方法在jQuery中。春季3 jquery阿贾克斯删除
这是我的js,控制器(spring 3)和来自Chrome的请求。
如果你现在是什么错误请告诉,或给一些链接。
$.ajax({
url: 'additions/cancelUpload',
type: 'DELETE',
data: {filename : ui.draggable.get(0).file.name},
success: function (res) {
alert(res);
}
});
执行不经过这里:
@RequestMapping(value = "cancelUpload", produces="text/html")
@ResponseBody
public String cancelUpload(@RequestParam("filename")String filename, HttpSession session){
...
}
要求:
Request URL:http://localhost:8080/WebStore/additions/cancelUpload Request Method:DELETE Status Code:400 Bad Request Request Headersview source Accept:*/* Accept-Charset:windows-1251,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:uk-UA,uk;q=0.8,ru;q=0.6,en-US;q=0.4,en;q=0.2 Connection:keep-alive Content-Length:17 Content-Type:application/x-www-form-urlencoded Cookie:JSESSIONID=A7DF5CB262C460961BC7B5C7DCB23052 Host:localhost:8080 Origin:http://localhost:8080 Referer:http://localhost:8080/WebStore/items?form User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1 1X-Requested-With:XMLHttpRequest Form Dataview URL encoded filename:6648.jpg
响应头
Connection:close Content-Length:1043 Content-Type:text/html;charset=utf-8 Date:Sat, 26 May 2012 10:03:58 GMT Server:Apache-Coyote/1.1 X-TraceId:4fc0a8f8-46 X-TraceUrl:/insight/services/traces/4fc0a8f8-46?type=json
看来你设置的内容类型为文本的方法/ html和服务要求它是应用程序/ x-www-form-urlencoded – toniedzwiedz
但我确实从js发送Content-Type:application/x-www-form-urlencoded。 并生产=“text/html”是服务器的响应。 我试图改变它,因为你说,但它是行不通的。 –
当我更改POST请求时,一切正常。 –