1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    52
    Answers
    2
    Vote Rating
    1
    testvogel is on a distinguished road

      0  

    Default Answered: Ajax.request callback, no reference to controller

    Answered: Ajax.request callback, no reference to controller


    Hi,

    I'm doing a Ajax request in my controller and have defined a callback method which should be called after the request:

    Code:
    			Ext.Ajax.request({
    				url: 'http://192.168.137.1:8080/example/',
    				method:'POST', 
    				headers: {
    					'Content-Type': 'application/json'
    				}, 
    				callback: this.ajaxResponse,
    				params: Ext.JSON.encode(form.getValues())
    			})
    ajaxResponse will be called, but after this ajax request I want to change the view and dont have a reference to this controller with 'this'. This means that

    Code:
     this.addRef(....)
    is not working, because addRef is unknown.
    Any ideas why I have loose the controller reference?

  2. Code:
    Ext.Ajax.request({
    				url: 'http://192.168.137.1:8080/example/',
    				method:'POST', 
    				headers: {
    					'Content-Type': 'application/json'
    				}, 
                                    scope : this,
    				callback: this.ajaxResponse,
    				params: Ext.JSON.encode(form.getValues())
    			})

  3. #2
    Sencha User
    Join Date
    Nov 2011
    Posts
    52
    Answers
    2
    Vote Rating
    1
    testvogel is on a distinguished road

      0  

    Default


    Hi,

    var controller = CheckoutDemo.controller.MainController;

    returns

    function (){return this.constructor.apply(this,arguments)}

    ??? I'm expecting an object and not a function?!

    However, controller.addRef(...) is not working.

  4. #3
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Answers
    102
    Vote Rating
    77
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Code:
    Ext.Ajax.request({
    				url: 'http://192.168.137.1:8080/example/',
    				method:'POST', 
    				headers: {
    					'Content-Type': 'application/json'
    				}, 
                                    scope : this,
    				callback: this.ajaxResponse,
    				params: Ext.JSON.encode(form.getValues())
    			})

Thread Participants: 1