-
17 Aug 2012 12:07 PM #1
Cannot load stores using jsonp extjs4.1
Cannot load stores using jsonp extjs4.1
I am trying to load ext data stores using jsonp. The below code is working fine when i am using ajax and making requests on the same domain.
When i run the code i see an error on firebug:Code:var baseUrl = 'http://localhost:8090/'; Ext.define('Ktimatologio.store.NewWholeBlockStore', { extend: 'Ext.data.Store', alias: 'widget.newsingleblockstore', requires: ['Ktimatologio.model.NewWholeBlockModel'], model: 'Ktimatologio.model.NewWholeBlockModel', groupField: 'search_tag', fields: [ {name:'id', mapping:'id'}, {name:'id1', mapping:'id1'}, {name: 'text', mapping: 'text'}, {name: 'title', mapping: 'title'}, {name: 'fek', mapping: 'fek'}, {name: 'date', mapping: 'date'}, {name: 'descr', mapping: 'description'}, {name: 'model', mapping: 'model'}, {name: 'body', mapping: 'body'}, {name: 'type', mapping: 'type'}, {name: 'history', mapping: 'history'}, {name: 'src', mapping: 'url'}, {name: 'search_tag', mapping: 'search_tag'}, {name: 'new_element', mapping: 'new_element'}, {name: 'new_table', mapping: 'new_table'} ], autoLoad: true, proxy: { //type:'ajax', type:'jsonp', url: baseUrl + 'openbd/ktimatologio-final/resources/cfScripts/nea_stoixeia/GetNewTables.cfc?', extraParams: { method: 'getNewTables' }, reader:{ type: 'json', root: 'data' } }
I am stuck!Code:SyntaxError: invalid label {"data":[{"id":"1_n_2308_1995","id1":1,"title":"Άρθρο 1 ΦΕΚ Α΄ 114 15.6.... GetNew...llback2 (line 1, column 1)
Any help is much appreciated!
Tom
Greece
-
18 Aug 2012 3:56 AM #2Sencha - Community Support Team
- Join Date
- Nov 2007
- Location
- Helsingborg, Sweden
- Posts
- 2,455
- Vote Rating
- 52
Is the server responding correctly? Did you verify the response?
-
18 Aug 2012 5:35 AM #3
Thank you for your reply,
Te response is 100% pure JSON. Still not get it. I am wresting with this a week now!
The response:
Any help is much appreciated!Code:{"data":[{"id":"13_gnomodotiseis","id1":13,"title":"5/2009 ΓΝΜΔ ΕΙΣΑΠ<br/> 2009","text":"5/2009 ΓΝΜΔ ΕΙΣΑΠ<br/>","model":"gnomodotiseis","body":"(Δ/ΝΗ 2009/302)<br/>•\tΚτηματολόγιο.<br/>•\tΗ αποδεκτή απόκλιση της τιμής του καταχωρισθέντος στο κτηματολογικό φύλλο του ακινήτου εμβαδού, σε σχέση προς την τιμή που προκύπτει από την εμβαδομέτρηση με μέθοδο ακριβέστερη από την προβλεπόμενη στις τεχνικές προδιαγραφές του κτηματολογίου, αποτελεί στοιχείο του αποσπάσματος του κτηματολογικού διαγράμματος και του κτηματογραφικού διαγράμματος του ακινήτου.<br/>•\tΔημοσίευση σχετικής απόφασης του Δ.Σ. του ΟΚΧΕ.<br/>•\tΚατά τη σύνταξη αγοραπωλητήριων συμβολαίων τέτοιων ακινήτων, υπάρχει υποχρέωση του μηχανικού που συντάσσει τοπογραφικό διάγραμμα να βεβαιώνει τη συμβατότητα προς τις καταχωρήσεις στο κτηματογραφικό διάγραμμα του ακινήτου.<br/>•\tΣυνέπειες μη τήρησης της υποχρέωσης αυτής για το μηχανικό και το συμβολαιογράφο.<br/>Αντεισαγγελέας: Βασίλει...","type":"text","history":"old","url":"","search_tag":"Γνωμοδοτήσεις","new_element":"true"}],"dataset":1}
-
18 Aug 2012 6:36 AM #4Sencha - Community Support Team
- Join Date
- Nov 2007
- Location
- Helsingborg, Sweden
- Posts
- 2,455
- Vote Rating
- 52
It should not be json, it should be javascript - a function. Details here
http://remysharp.com/2007/10/08/what-is-jsonp/
-
18 Aug 2012 7:02 AM #5
-
18 Aug 2012 7:55 AM #6
Still having problem,
The response:
The url:Code:callback({ "data": [ { "id": "13_gnomodotiseis", "id1": 13, "title": "5/2009 ΓΝΜΔ ΕΙΣΑΠ 2009", "text": "5/2009 ΓΝΜΔ ΕΙΣΑΠ ", "model": "gnomodotiseis", "body": "σίλει...", "type": "text", "history": "old", "url": "", "search_tag": "Γνωμοδοτήσεις", "new_element": "true" } ], "dataset": 1 })
The store:Code:http://localhost:8090/openbd/ktimatologio-final/resources/cfScripts/nea_stoixeia/GetNews.cfc?&_dc=1345305032559&method=jsonP&page=1&start=0&limit=25&group=[{"property"%3A"search_tag"%2C"direction"%3A"ASC"}]&sort=[{"property"%3A"search_tag"%2C"direction"%3A"ASC"}]&callback=Ext.data.JsonP.callback2
Firebug gives me error: "ReferenceError: callback is not defined"Code:var baseUrl = 'http://localhost:8090/'; Ext.define('Ktimatologio.store.NewSingleBlockStore', { extend: 'Ext.data.Store', alias: 'widget.newsingleblockstore', requires: ['Ktimatologio.model.NewSingleBlockModel'], model: 'Ktimatologio.model.NewSingleBlockModel', groupField: 'search_tag', fields: [ {name:'id', mapping:'id'}, {name:'id1', mapping:'id1'}, {name: 'text', mapping: 'text'}, {name: 'title', mapping: 'title'}, {name: 'fek', mapping: 'fek'}, {name: 'date', mapping: 'date'}, {name: 'descr', mapping: 'description'}, {name: 'model', mapping: 'model'}, {name: 'body', mapping: 'body'}, {name: 'type', mapping: 'type'}, {name: 'history', mapping: 'history'}, {name: 'src', mapping: 'url'}, {name: 'search_tag', mapping: 'search_tag'}, {name: 'new_element', mapping: 'new_element'}, {name: 'new_table', mapping: 'new_table'} ], autoLoad: true, proxy: { //type:'ajax', type:'jsonp', url: baseUrl + 'openbd/ktimatologio-final/resources/cfScripts/nea_stoixeia/GetNews.cfc?', callbackKey: 'callback', extraParams: { method: 'jsonP' }, reader:{ type: 'json', root: 'data' } } });
Where does Ext.data.JsonP.callback2 pops up in the url?
-
18 Aug 2012 10:19 PM #7
Because that's the function it's expecting to call. It's covered in the docs: http://docs.sencha.com/ext-js/4-0/#!...ta.proxy.JsonP
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!


Reply With Quote