私はextjs4 MVCで作業しており、単一のリクエストでオブジェクト配列を送信する方法で行き詰まっています。単一のオブジェクトをサーバーに送信する方法を知っています。
1)ここに私のコントローラーコードがあります:-
check:function () {
console.log("Inside check function.");
//creating objects in javascript
var obj = new Object();
for (var i = 0; i < 4; i++) {
var inputs = document.getElementsByName(i);
var radio = "";
for (var j = 0; j < inputs.length; j++) {
if (inputs[j].checked) {
name = inputs[j].name;
value = inputs[j].value;
//obj[i].name1=name;
obj[i] = {'questionId': name, 'option': value};
console.log("questionId=" + name + " value=" + value);
console.log("object name=" + obj[i].questionId + " Object value=" + obj[i].option);
var check = Ext.ModelManager.create(
{
questionId: name,
option: value,
}, 'Balaee.model.qb.QbquestionoptionModel');
console.log("User Infooooooooo:" + check.get('option'));
}// End of if statment
}// End of inner for loop
}//End of outer for loop
var storeObject = this.getStore('qb.QbquestionoptionStore');
storeObject.sync();
console.log("data send");
}// End of check function
2)モデルクラス:---
Ext.define('Balaee.model.qb.QbquestionoptionModel',{
extend: 'Ext.data.Model',
idproperty:'',//fields property first position pk.
fields: ['optionId','questionId','isAnswer','option','media','keyword','mediaTypeId',],
/*associations:[
{type:'BelongsTo', model:'Mediatype', foreignKey:'mediaTypeId'},
{type:'BelongsTo', model:'Qbquestion', foreignKey:'questionId'},
{type:'HasMany', model:'Qbregistereduserfreequestionawnser', foreignKey:'answerOptionId'},
]*/
});
3) ここに私の店:---
Ext.define('Balaee.store.qb.QbquestionoptionStore',{
extend: 'Ext.data.Store',
model: 'Balaee.model.qb.QbquestionoptionModel',
//autoLoad: true,
proxy:
{
type:'ajax',
api:
{
read:'http://localhost/balaee/Balaee/index.php?r=QuestionBank/qbpaper/SetUserAnswer11',
create: 'http://localhost/balaee/Balaee/index.php?r=QuestionBank/qbpaper/SetUserAnswer12',
update: 'http://localhost/balaee/Balaee/index.php?r=QuestionBank/qbpaper/SetUserAnswer13',
//destroy: ,
},//End of api
reader:
{
type:'json',
//root: ,
//successProperty: ,
},//End of reader
writer:
{
type:'json',
root:'data'
}
}//End of proxy
});//End of store
どうすればこれを解決できますか? いくつかの提案をしてください....