-
22 Jun 2012 4:52 AM #1
Answered: How to change url in jsonp proxy?
Answered: How to change url in jsonp proxy?
I define a jsonp proxy to read data out of iTunes, the url is
http://itunes.apple.com/search?entity=album&term=... (... is the search string)
It works for a given search string.
How can I set the url dynamically. I tried to use the beforeload event with store.setProxy, but I do not manage to replace the url in the network call.
Is there an automatic way of passing parameters to the store/proxy so that the proxy handles the url extension?
Best regards
hebr3
-
Best Answer Posted by mitchellsimoens
Have you tried using the setUrl method on the proxy?
-
24 Jun 2012 2:08 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
Have you tried using the setUrl method on the proxy?
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.
-
25 Jun 2012 5:52 AM #3
I don't find the setUrl-method, does it really exist?
I did now
Code:... var p=this.getProxy().getInitialConfig(); p.url = 'http://itunes.apple.com/search?entity=album&attribute=allArtistTerm&term='+searchValue; this.setProxy(p); ...
-
25 Jun 2012 5:59 AM #4
-
25 Jun 2012 6:20 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
All properties in the config object in all classes get a setter and getter created. If you look at Ext.data.proxy.Server url is in the config object so it has a setUrl and getUrl method created for it. Ajax and JsonP proxy extends Server proxy, in buildRequest (where the url is used) it executes the getUrl which simply returns the _url propery that the setUrl will change so it should always update to use the new url.
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.
-
25 Jun 2012 6:28 AM #6
I understand assuming config options have mutators and accessors; I'm just saying that if there were documentation included for those getters and setters, and a majority does, then some questions like these could be prevented, at least for those users who turn to the docs before the forum.
-
25 Jun 2012 3:32 PM #7
I was having the same problem and after few hours of try and errors and found a solution:
//get the store
var store =Ext.getStore('myLittleStore');
//get the store proxy
var proxy=store .getProxy();
//change the url
proxy.setUrl('new url go here');
//re-load the store with new data
store .load();


Reply With Quote
