2

在 Backbone 中,有一个“DELETE”。

this.model.url = '/js/products/123/destroy';
this.model.destroy();

我如何在 JQuery 中模拟这个?

在我的 node.js 应用程序中,我专门寻找 app.delete。

.   Request URL:http://mydomain.com/js/products/2/destroy
.   Request Method:DELETE
.   Status Code:200 OK
.   Request Headersview source
.   Accept:application/json, text/javascript, */*; q=0.01
.   Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
.   Accept-Encoding:gzip,deflate,sdch
.   Accept-Language:en-US,en;q=0.8
.   Connection:keep-alive
.   Cookie:connect.sid=s%3ALmcKt2dNgSzfQCyCAcVlPeg6.bFXUPlpuZctDpfN2Gu5mtslVC9nA3FOi908Qe8aExYY
.   Host:mydomain.com
.   Origin:http://mydomain.com
.   Referer:http://mydomain.com/1
.   User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31 AlexaToolbar/alxg-3.1
.   X-Requested-With:XMLHttpRequest
.   Response Headersview source
.   Connection:keep-alive
.   Content-Length:27
.   Content-Type:text/html; charset=utf-8
.   Date:Sun, 14 Apr 2013 02:57:17 GMT
.   X-Powered-By:Express
4

1 回答 1

9

看看这里

在您的情况下,这将转化为:

$.ajax({
    url: '/js/products/123/destroy',
    type: 'DELETE',
    success: function(result) {
        // Do something with the result
    }
});
于 2013-04-14T02:56:41.147 回答