Results 1 to 3 of 3

Thread: Ajax.request callback, no reference to controller

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    52
    Answers
    2
    Vote Rating
    1
      0  

    Default 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
      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
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Answers
    102
    Vote Rating
    86
      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())
    			})

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •