Hybrid View
-
7 Nov 2011 6:49 AM #1
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:
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 thatCode: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()) })
is not working, because addRef is unknown.Code:this.addRef(....)
Any ideas why I have loose the controller reference?
-
Best Answer Posted by jay@moduscreate.comCode:
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()) })
-
7 Nov 2011 8:23 AM #2
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.
-
7 Nov 2011 8:35 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
- Answers
- 83
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()) })
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.


Reply With Quote