-
29 Mar 2012 7:00 AM #1
Ext Direct no callback if server returned junk
Ext Direct no callback if server returned junk
Version 4.1-rc1
File: Ext.direct.RemotingProvider
Code:onData: function(options, success, response){ var me = this, i = 0, len, events, event, transaction, transactions; if (success) { events = me.createEvents(response); for (len = events.length; i < len; ++i) { event = events[i]; transaction = me.getTransaction(event); me.fireEvent('data', me, event); if (transaction) { me.runCallback(transaction, event, true); Ext.direct.Manager.removeTransaction(transaction); } } } else {
transaction variable is null when server returned junk.
That is why no callback is called.
The same result if server returned empty text. Javascript error appears, no callback received.Last edited by yozik04; 29 Mar 2012 at 7:12 AM. Reason: empty text
-
29 Mar 2012 11:35 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
Thanks for the report.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
29 Mar 2012 4:18 PM #3
For a direct request to be processed, it needs to return a valid set of JSON data, otherwise we can never identify which transactions we need to process, this is especially important when we consider request batching.
The provider will fire a "data" event each time it receives data. In the cases where it can't parse the event, it will send an exception object as the parameter to the data event.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
3 Sep 2012 5:11 AM #4
I found a way to do it... adding a listener (exception) on direct and "forcing" to execute the code in the callback:
the main app code:
....Code:Ext.direct.Manager.addProvider(Ext.app.REMOTING_API); Ext.direct.Manager.on('exception', function(opts) { opts.xhr.request.options.transaction.callback(null, null); }, this);
the direct request code (it could be in some controller):
....Code:Ext.app.myClass.myMethod(params, function(provider, response){ if(response == null) { alert("Server error"); } else { console.log(response.result) //your code } });
the server side code (example of error)
So in this way I found a simple 'trick' to handle some problem about server system, php notice & warning and so on...Code:<?php public function myMethod($params) { return 5/0; //<--- this will produce a "division by zero" php Warning } //...
I'm not a extjs guru =) and I'd like to know what sencha devs think about it, thank you.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote