【问题标题】:Submit Extjs form via PUT Method通过 PUT 方法提交 Extjs 表单
【发布时间】:2012-11-29 06:23:17
【问题描述】:

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

这是我的代码:

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。 谢谢

【问题讨论】:

    标签: extjs


    【解决方案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);
            }
     );
    

    【讨论】:

      【解决方案2】:

      我没有尝试过,但据我了解,以下方法可能有效:

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

      【讨论】:

        【解决方案3】:

        我对轨道一无所知...
        但我习惯了这样的couchdb

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-12-20
          • 1970-01-01
          • 2012-08-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多