-
21 Aug 2012 6:21 PM #1
Unanswered: problem using ajax proxy
Unanswered: problem using ajax proxy
Hi
I am new to sencha. Please help.
I have to create a nested list & I have a api in php which returns data in heirarchical order. I have to write proxy for that.
I tried
and my modelCode:new Ext.data.Store({ model: 'kategorieModel', autoLoad: true, storeid:'kategorieStore', proxy: { type: 'ajax', url: 'myurl', extraParams:{request:'offers_list'}, limitParam: '', noCache: false, useNull: true, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, reader : { type : 'json', encode : 'false', root : 'kategorie_name', } } });
but it's not working. I am not getting any response.Code:Ext.regModel('kategorieModel', { fields: [ {name: 'kategorie_name', type:'string'} ]});
I have an already existing working request for this api which I have to use .
This is returning json data in required heirarchical orderCode:$.ajax({ url: 'myurl', type:'POST', data:{ request:'offers_list', params:{}}, success: function(data) { var json = eval('('+data+')'); addDataToStore(json); } });
please help me create a nested list using the info above. Can I directly use the second $.ajax given and add it to treestore and a nestedlist. If yes please help me with a small code sample . I am not able to get it work
-
23 Aug 2012 6:27 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 434
- Answers
- 3102
What is being returned?
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 Aug 2012 8:26 PM #3
Hi,
I am getting following error messages
XMLHttpRequest cannot load <myurl>. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.
I modified the code to
now I am getting following error message:Code:var store = new Ext.data.TreeStore({ autoLoad: true, storeid:'myapp.stores.kategorieStore123', model:'myapp.models.kategory', proxy: { type: 'scripttag', url: 'myurl', limitParam: '', noCache: false, useNull: true, callbackParam:'error_code:0', callbackPrefix:'', model:'myapp.models.kategory', scriptIdPrefix:'', writer:'json', headers: { 'Content-Type': 'Content-Type: application/x-json' }, reader : { type : 'json', encode : 'false', root : 'output' } } });
Uncaught SyntaxError: Unexpected token : api:1
and when I click on api:1 I get the exact output that is returned by the api.
it is like this below
{"error_code":0,"error_message":"","output":{"Urlaub & Reisen":[{"id":"33770","name":" A&O HOTELS und HOSTELS","beschreib.......
It appears it is objecting to error_code":0 . But I have a jquery request to the same api & it works fine with this data as output.
I cannot modify anything at server end so I have to handle whatever it is in my call from sencha touch.
Please help


Reply With Quote