如何使用Ext.Ajax.request将数组发送到Jsp?

时间:2013-11-06 08:23:58

标签: extjs extjs4

我的HTML文件中有一个数组,想要在按钮提交时使用Ext.Ajax.request将其发送到Jsp文件... 我的代码是:

Ext.onReady(function() {
Ext.create('Ext.data.Store', {
    storeId:'myArray',
    fields:['id','name', 'email'],
    data:{'items':[
        {"id":"1", "name":"Lisa", "email":"lisa@ArrayData.com"},
        {"id":"2", "name":"Bart", "email":"bart@ArrayData.com"},
        {"id":"3", "name":"Homer", "email":"home@ArrayData.com"},
        {"id":"4", "name":"Marge", "email":"marge@ArrayData.com"}
    ]},
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'items'
        }
    }
});


Ext.create('Ext.Button', {
    text: 'Click me',
    renderTo: Ext.getBody(),
    handler: function() {
        {
        Ext.Ajax.request({
    url: 'prac.jsp',
    method: 'POST',
    jsonData: myArray,
    success: function() {
        console.log('success');
    },
    failure: function() {
        console.log('woops');
    }
});
    }
    }
});

});

我在Firebug中遇到了这个错误:

太多的递归

return toString.call(value)==='[object Date]';

1 个答案:

答案 0 :(得分:-1)

我发布了实际代码的错误部分。真的很抱歉这个混乱......工作代码是:::

Ext.onReady(function() {
var array_edited=Ext.create('Ext.data.Store', {
    storeId:'myArray_edited',
    fields:['id','name', 'email'],
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'items'
        }
    }
});

Ext.create('Ext.Button', {
    text: 'Click me',
    renderTo: Ext.getBody(),
    handler: function() {
        {
        Ext.Ajax.request({
    url: 'newjsp.jsp',
    method: 'POST',
    params: {arr: array_edited},
    callback: function (options, success, response) {
    if (success) {
    var json = Ext.JSON.decode(response.responseText);
       Ext.MessageBox.alert('Add Profile Info', json.msg);
    }
    },
    //jsonData: array_edited,
    success: function() {
        console.log('success');
    },
    failure: function() {
        console.log('woops');
    }
});
    }
    }
});

});