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

  • Home
  • SEARCH
  • 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 8079833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:14:07+00:00 2026-06-05T16:14:07+00:00

I’m trying to build a simple user setting feature for my school project. I’ve

  • 0

I’m trying to build a simple user setting feature for my school project.
I’ve created a data model like so:

Ext.define('Urlopy.Model.UserPreferences', {
        extend : 'Ext.data.Model',
        idProperty : 'userID',
        fields : [{
                    name : 'userID',
                    type : 'string'
                }, {
                    name : 'admin',
                    type : 'bool'
                }]
    });

and a store like this:

Ext.define('Urlopy.Store.UserPreferences', {
        extend : "Ext.data.Store",
        autoLoad : false,
        autoSync : true,
        batch : false,
        proxy : {
            type : 'ajax',
            sortParam : undefined,
            startParam : undefined,
            pageParam : undefined,
            limitParam : undefined,
            noCache : false,
            headers : {
                "Content-Type" : "application/json; charset=utf-8"
            },
            api : {
                read : 'services/UserPreferences.asmx/Get',
                update : 'services/UserPreferences.asmx/Update'
            },
            reader : {
                type : 'json',
                root : 'd.data'
            },
            writer : {
                type : 'json',
                encode : false,
                writeAllFields : true,
                root : 'data'
            }
        },
        model : 'Urlopy.Model.UserPreferences'
    });

In my application when user logs in I would like to get his preferences.

I have a function like so:

onLogin : function() {

            this.createGlobalStores();

            this.userPreferenceStore.load({

                        callback : function(r, options, success) {
                            console.log(r.data)
                        }

                    });

        },
        createGlobalStores : function() {
            this.userPreferenceStore = Ext.create("Urlopy.Store.UserPreferences");
        },

What I would like to do in callback is to get userID and display it, even using simple alert.

Right now all I get is undefined that shows in firebug.

My json data from server looks like this:

{"d":{"__type":"Urlopy.services.UserPreference","userID":"12445","admin":true}}

I need to be able to call load method on that store and in callback get specific property from model. My store will always have 1 item! (is there another way to do this?)

Any ideas on why this isn’t working are welcome!

EDIT
I’ve changed my server script to return json like this:

{"d":{"data":{"userID":"12-44-55","admin":true}}}

This works fine, there were no need to add extra [] around object.

  • 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-05T16:14:10+00:00Added an answer on June 5, 2026 at 4:14 pm

    First of all a load for a store expects an array, and second you set the root for the proxy wrong. since there is no d.data object in your json. Simple fix will be to encode your json data as an array with one element, and the tag for that array to be “data” …

    {"d":[{"__type":"Urlopy.services.UserPreference","userID":"12445","admin":true}]}
    

    and just set the root to d

    reader : {
        type : 'json',
        root : 'd'
    }
    

    After this on the callback you’ll have an array of records with one element that you can simply access with index 0

    callback : function(records, options, success) {
        console.log(records[0].data.userID +" " + records[0].data.admin);
    }
    

    EDIT

    Other method not involving stores

    Do a simple ajax request like:

    Ext.Ajax.request({
                url: 'services/UserPreferences.asmx/Get',
                params: {/*if you want any extra params to be sent*/},
                scope: this,
                success: function (result) {
                    var response = Ext.decode(result.responseText);
                    //this is for your initial json
                    alert(response.d.userID);
                },
                failure: function (result) {
                    alert('something failed')    
                }
            });
    

    I don’t know what you do with the data, but for example you can load it into a form, and for the update method then you will have the submit option for the form. which can be configured with the url where to send the data.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

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.