gpt4 book ai didi

jquery - Spring 3 jquery ajax删除

转载 作者:行者123 更新时间:2023-12-01 08:15:53 25 4
gpt4 key购买 nike

我正在尝试使用 jquery 进行 ajax 删除,但收到 http 错误 400。我正在搜索,发现jquery中的delete方法存在一些问题。

这是我的 js、 Controller (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/cancelUploadRequest Method:DELETEStatus Code:400 Bad RequestRequest Headersview sourceAccept:*/*Accept-Charset:windows-1251,utf-8;q=0.7,*;q=0.3Accept-Encoding:gzip,deflate,sdchAccept-Language:uk-UA,uk;q=0.8,ru;q=0.6,en-US;q=0.4,en;q=0.2Connection:keep-aliveContent-Length:17Content-Type:application/x-www-form-urlencodedCookie:JSESSIONID=A7DF5CB262C460961BC7B5C7DCB23052Host:localhost:8080Origin:http://localhost:8080Referer:http://localhost:8080/WebStore/items?formUser-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.11X-Requested-With:XMLHttpRequestForm Dataview URL encodedfilename:6648.jpg

响应 header

Connection:closeContent-Length:1043Content-Type:text/html;charset=utf-8Date:Sat, 26 May 2012 10:03:58 GMTServer:Apache-Coyote/1.1X-TraceId:4fc0a8f8-46X-TraceUrl:/insight/services/traces/4fc0a8f8-46?type=json

最佳答案

我设法收到删除请求

 @RequestMapping(value = "cancelUpload", produces="text/html" method = RequestMethod.DELETE)

但是这样做

$.ajax({  
url: 'additions/cancelUpload',
type: 'POST',
data: {filename : ui.draggable.get(0).file.name, _method: 'DELETE'},
success: function (res) {
alert(res);
}
});

您可以在 http://blog.springsource.org/2009/03/08/rest-in-spring-3-mvc/ 中阅读有关 _method: 'DELETE' 参数的 post 请求

如果有人现在如何发送真正删除 AJAX 请求。请告诉我

关于jquery - Spring 3 jquery ajax删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10766195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com