如何通过json发送extjs数据

时间:2013-02-16 07:03:43

标签: json extjs

我正在工作。我想通过json发送文本字段数据。所以我写了代码 -

Ext.define('Balaee.controller.kp.WordController',{
    extend: 'Ext.app.Controller',
    stores: ['kp.WordStore'],
    models: ['kp.WordModel'],
    views: ['kp.Word.Word'],
    refs:[
       {
            ref:'wordtext',
            selector:'textfield[name=wordtext]'
       },
       ],
    init: function() {
        console.log('Inside word controller');
        this.control(
                {
            'Word button[action=SearchAction]':
            {
                click:this.SearchWord
            },

        });//End of control
    },//End of init() function

    SearchWord:function(button)
    {
        var j = Ext.getCmp('wordtext').getValue();
        console.log("word is:"+j);


                            var wordObject = Ext.ModelManager.create(
                {

                    word:Ext.getCmp('wordtext').getValue(),
                },'Balaee.model.kp.WordModel');


        wordObject.save({    
            success: function(record, operation) 
            {
                console.log("registration successssssssssss  "+record);
            },//End of success function
            failure: function(record, operation) 
            {
                console.log("Inside failure functionnnnn");
            },//End of failure function
            callback: function(record, operation)
            {
                console.log("Inside callback functionnnnnn");   
                console.log(record);
            }//End of callback function
        });// End of
    },


});//End of Controller

但它总是失败的功能。那么我还需要做些什么呢?请有人请帮助我......

1 个答案:

答案 0 :(得分:0)

尝试使用此方法创建WordModel实例:

    var wordObject = Ext.create(
      'Balaee.model.kp.WordModel',
      { word : j }
    );

或者您可能需要在模型中配置代理