通过PUT方法提交Extjs表单

3

是否可以通过HTTP PUT方法提交extjs表单? 我想在接受PUT方法更新的Rails 3上更新记录。

这是我的代码:

formData.submit({       url: "/layers/" + param.layer_id + "/rules_property_thresholds/" + param.id ,
        method:'PUT',
        params: param,
        waitTitle: "Please wait...",
            waitMsg: 'Updating rule property threshold...',
                    .........
             });

我使用PUT方法,但在查看Firebug(Net)时,请求仍然以POST方式进行。谢谢。

3个回答

1

目前只有HTML5可以直接通过表单支持PUT。到目前为止,表单仅支持GETPOST

现在您需要使用ajax通过PUT提交表单:

Ext.Ajax.request({
        url: 'your url', // you can fix a parameter like this : url?action=anAction1
        method: 'PUT',
        params: {
            myField1: myField1.getValue()
            // all your params.... 
        }
        success: function (result, request){
            alert('Succesfully added ' + result.responseText);
        },
        failure: function (result, request){
            alert('Error in server' + result.responseText);
        }
 );

0

我没有尝试过,但据我理解,以下内容可能有效:

myForm.on('beforeaction', function(form, action) {
    action.options.method = 'PUT';
});

-1

我对Rails一无所知...
但我习惯于像这样使用CouchDB

var a = {
    _id : "gordon",
    xtype : "user"
}

Ext.Ajax.request({
    method : "PUT",
    url: "/db/egy",
    jsonData : a,
    success : function(){
    console.log("aaa");
    }
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接