1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    Shanghai, China
    Posts
    21
    Vote Rating
    1
    Answers
    1
    tianhao is on a distinguished road

      0  

    Default Unanswered: how to pass a parameter through ajax

    Unanswered: how to pass a parameter through ajax


    hi all,
    i have finished an ajax grid. it works good. here is the code:
    xtype: 'gridpanel',
    id: 'mygrid',
    ......
    store: Ext.create('Ext.data.Store',{proxy: {type: 'ajax',url: 'duty.json.ajax.php',reader: {...}}})
    this is ok. but when i add a parameter to url of proxy, it doesnt work. i replace url with
    url: 'duty.json.ajax.php?id='+Ext.getCmp('id').getValue()
    the web console of firefox said
    TypeError: Ext.getCmp("id") is undefined
    and nothing was displayed.
    plz help me.

  2. #2
    Sencha User mixo's Avatar
    Join Date
    Jul 2011
    Location
    Novosibirsk
    Posts
    49
    Vote Rating
    3
    Answers
    4
    mixo is on a distinguished road

      0  

    Default


    hello

    I guess your problem not in ajax. what you expect to get by Ext.getCmp('id').getValue()?
    First step is try manually get this value by typing in console Ext.getCmp('id').getValue().

    I think there is bad style use an ID of cmp, if it's possible better access to cmp is call for parent cmp like this

    Code:
    cmp = parent_cmp.down('[name=cmpName]')

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    Shanghai, China
    Posts
    21
    Vote Rating
    1
    Answers
    1
    tianhao is on a distinguished road

      0  

    Default


    it didnot work
    console prompted ok when i run Ext.getCmp('id').getValue(). the result is 4. that is right.
    any help will be appreciated.

  4. #4
    Sencha User mixo's Avatar
    Join Date
    Jul 2011
    Location
    Novosibirsk
    Posts
    49
    Vote Rating
    3
    Answers
    4
    mixo is on a distinguished road

      0  

    Default


    Strip calculate url and ajax request


    Code:
    myUrl = 'duty.json.ajax.php?id='+Ext.getCmp('id').getValue()
    console.log(myUrl);
    ...
    url: myUrl

  5. #5
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
    Answers
    106
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    You can also do this:

    Code:
    yourGrid.getStore().load({
      params: {
        someParam: 'someValue'
      }
    });

Thread Participants: 2