Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:20:45+00:00 2026-06-17T19:20:45+00:00

i am working in extjs4 MVC and I have been getting stuck at a

  • 0

i am working in extjs4 MVC and I have been getting stuck at a point which is how to send object array in a single request.
I know how to send single object to server.

1)Here is my some controller code :-

    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)Model class :—

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)Here is my store :—

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

how can I solve this? please give some suggestion….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:20:46+00:00Added an answer on June 17, 2026 at 7:20 pm

    Well, first you have to send it as JSON (at least I recommend that) and that can easily be done cause the Ext.Ajax.request() method supports this out of the box

    Ext.Ajax.request({
        url: 'YourURL',
        jsonData: YourObjectRef, // can be any object or JSON string
        success: function(response, opts) {
            // your code
        }
    });
    

    And if you want to do it with a store use the type auto for the Modelfield. This type can contain any object. Here’s a JSFiddle with a list of objects within a model.

    Here is a modification of your store configuration. Note that you can either define a read only API or a CRUD API. For the later it is not possible to leave f.e. the destroy action unset. You also need to know that a root property within the writer implies that you want to encode your data, meaning all get send via get which is defiantly not what you want.

    Now to what this proxy does: Per default batch will be true which would cause the store to submit all changes at once when sync get called. If there are more then one changes for a action the proxy will submit a array of objects instead of a single one. Now if you don’t take care about this you would now need to predict if you get a object or a array of objects for each request. We don’t want end up in something like this. But there is the allowSingle property on the writer which get us around this. If you set it to true it will always send a array of objects back to the server even if there is only one. You now know that you get a array each time.

    proxy:{
        type:'ajax',
        api: {
            read:'index.php?r=...',
            create: 'index.php?r=...',
            update: 'index.php?r=...',
            destroy: 'index.php?r=...',
        },
        reader: {
            type:'json',
            root:'data'
        },
        writer: {
            type:'json',
            allowSingle: false
        }   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working in extjs4 MVC where I have been working on task to
I am working with Extjs4.1 MVC. What I am trying to do is save
I am working on an Extjs portal example and downloaded the example from extjs4-mvc-portal
I have developed a web application using ExtJs4.0.7. The application is working fine in
As we know that ExtJS4 is new,we will get stuck with some problems even
I am working with ASP.NET MVC and have a view page with a simple
I am working on extjs4, my case is: Extjs mvc is used to build
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Hello and happy holidays everyone. Recently I have been tasked with transforming a beta
I'm working on a project with Extjs, version 4.0.7 and i have a problem.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.