Created
May 3, 2012 22:59
-
-
Save shanesmith/2590198 to your computer and use it in GitHub Desktop.
Extended proxy to resolve Android 3+ url param bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Android 3+ doesn't like url params | |
* for file:// ajax request, so let's remove them! | |
*/ | |
Ext.define('MyApp.proxy.NoParamAjax', { | |
extend: 'Ext.data.proxy.Ajax', | |
alias: 'proxy.noparamajax', | |
/** | |
* Set config to remove auto params | |
*/ | |
config: { | |
noCache: false, | |
enablePagingParams: false, | |
}, | |
/** | |
* Copied from Ext.data.proxy.Ajax, modified to remove params | |
*/ | |
doRequest: function(operation, callback, scope) { | |
var writer = this.getWriter(), | |
request = this.buildRequest(operation); | |
request.setConfig({ | |
headers : this.getHeaders(), | |
timeout : this.getTimeout(), | |
method : this.getMethod(request), | |
callback : this.createRequestCallback(request, operation, callback, scope), | |
scope : this | |
}); | |
if (operation.getWithCredentials() || this.getWithCredentials()) { | |
request.setWithCredentials(true); | |
} | |
request = writer.write(request); | |
var requestCfg = request.getCurrentConfig(); | |
// remove all url params for Android 3+ compatibility | |
requestCfg.params = {}; | |
Ext.Ajax.request(requestCfg); | |
return request; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment