-
30 Jun 2012 1:11 PM #1
Answered: Modify 'Store' to read data from URL instead of local file - Beginner
Answered: Modify 'Store' to read data from URL instead of local file - Beginner
I have a PHP code in the server that will return all 'Book' information in the form of a JSON string. The URL is http://localhost/all_books.php
The following STRORE code, that will load the JSON values from a local file called books.json. What i want it to do is to load the JSON records from the URL http://localhost/all_books.php. How can i modify the code to do so ?
Code:Ext.define('App.store.Book', { extend: 'Ext.data.Store', model: 'App.model.Book', proxy: { type: 'ajax', url: 'data/books.json' } });
-
Best Answer Posted by scottmartin
Have a look at JSONP to load data from another domain.
http://docs.sencha.com/ext-js/4-1/#!...ta.proxy.JsonP
Scott.
-
30 Jun 2012 3:06 PM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,188
- Vote Rating
- 194
- Answers
- 436
Have a look at JSONP to load data from another domain.
http://docs.sencha.com/ext-js/4-1/#!...ta.proxy.JsonP
Scott.
-
30 Jun 2012 9:28 PM #3
I get an error in Firebug, any clue why this is happening ? It says Invalid label and there's an arrow pointing to "id" in the JSON response .
My store class;Code:invalid label {"id":"1","name":"columbus"}
http://localhost/all_human.php Returns the above JSON
Code:Ext.define('Hum.store.Human',{ extend:'Ext.data.Store', model:'Hum.model.Human', proxy: { type: 'jsonp', url : 'http://localhost/all_human.php' } });
EDIT:
I need to pass 2 parameters to theall_human.php file. 'countryName' is the parameter. and this PHP file accepts POST. How can i pass parameters from the STORE class?
-
1 Jul 2012 12:01 PM #4Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,188
- Vote Rating
- 194
- Answers
- 436
My mistake .. are you going to be referencing a cross domain URL ... or will it always be localhost?
It was my understanding you wanted the qualified domain for accessing data from another location. If this is not the case, is there a problem with using a relative path instead requiring the full url to access a local file?
Scott.
-
2 Jul 2012 1:55 AM #5
I wanted to access the response from a Cross domain URL, but my program worked when i added the PHP files locally. Thank you.


Reply With Quote