weixin_33692284 2012-05-26 12:26 采纳率: 0%
浏览 47

Spring 3 jQuery Ajax删除

I am trying to do ajax delete with jquery but getting http error 400. I was searching and I've seen that there is some problems with delete method in jquery.

Here's my js, controller(spring 3) and request from Chrome.

If you now what is the mistake please tell, or give some links.

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

execution does not passed here:

@RequestMapping(value = "cancelUpload", produces="text/html")
    @ResponseBody
    public String cancelUpload(@RequestParam("filename")String filename, HttpSession session ){ 
... 
} 

request:

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

Response Headers

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
  • 写回答

2条回答 默认 最新

  • weixin_33739541 2012-05-26 18:00
    关注

    I manage to recive request as DELETE

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

    but do this with

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

    you can read about _method: 'DELETE' parameter of post request in http://blog.springsource.org/2009/03/08/rest-in-spring-3-mvc/

    IF SOME BODY NOW HOW TO SEND REALLY DELETE AJAX REQUEST. PLEASE TELL ME

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序