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 6725085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:45:55+00:00 2026-05-26T09:45:55+00:00

(ExtJS 4.0.7) I’m using Model.save() to PUT an update to a server. Everything works

  • 0

(ExtJS 4.0.7)

I’m using Model.save() to PUT an update to a server. Everything works fine and the server returns a simple JSON response {success: true} (HTTP status 200). Model.save() throws the following error, however:

Uncaught TypeError: Cannot read property 'data' of undefined

Here’s where this is happening in the ExtJS code (src/data/Model.js):

save: function(options) {
   ...
   callback = function(operation) {
      if (operation.wasSuccessful()) {
         record = operation.getRecords()[0]; <-- getRecords() return an empty array
         me.set(record.data); <-- record is undefined, so .data causes error
   ...
}

I’ve figured out this is happening because Model.save() expects the server to respond with JSON for the entire object that was just updated (or created).

Does anyone know of a clever way to make Model.save() work when the server responds with a simple success message?

  • 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-05-26T09:45:56+00:00Added an answer on May 26, 2026 at 9:45 am

    I was able to come up with a work-around by using a custom proxy for the model, and overriding the update function:

    Ext.define('kpc.util.CustomRestProxy', {
        extend: 'Ext.data.proxy.Rest',
        alias: 'proxy.kpc.util.CustomRestProxy',
        type: 'rest',
    
        reader : {
            root: 'data',
            type: 'json',
            messageProperty: 'message'
        },
    
        // Model.save() will call this function, passing in its own callback
        update: function(operation, callback, scope) {
    
            // Wrap the callback from Model.save() with our own logic
            var mycallback = function(oper) {
                // Delete the resultSet from the operation before letting
                // Model.save's callback use it; this will 
                oper.resultSet = undefined;
                callback(op);
            };
    
            return this.doRequest(operation, mycallback, scope);
        }
    });
    

    In a nutshell, when my proxy is asked to do an update it makes sure operation.resultSet == undefined. This changes the return value for operation.getRecords() (which you can see in the code sample from my question). Here’s what that function looks like (src/data/Operation.js):

    getRecords: function() {
        var resultSet = this.getResultSet();
        return (resultSet === undefined ? this.records : resultSet.records);
    }
    

    By ensuring that resultSet == undefined, operation.getRecords returns the model’s current data instead of the empty result set (since the server isn’t returning a result, only a simple success message). So when the callback defined in save() runs, the model sets its data to its current data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In extjs, I wish to update a boxcomponent (inside a tab)with a json response
I'm using extjs and just trying to solve a simple problem: I have a
Server side extjs form validation using zend framework I have extended Zend_Form class to
My extjs store is not loaded even if the server reutrns a correct json
ExtJS version is ext-4.0.7-gpl . When syncing a Store, the server returns me the
ExtJS Charts, I am using an Ext column chart and I want to implement
Using ExtJs. I'm trying to design a main which is divided into three sub
I have an ExtJS grid on a web page and I'd like to save
I am using the ExtJS framework and I have the following handler that is
I'm using ExtJS 2.2.1 In my web app, I used to have a TreePanel

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.