PDA

View Full Version : sencha fiddle ajax call!!!!!!!!!!!!!!!!!!!!!!!!!!!!



lbottoni
1 Feb 2016, 8:38 AM
Hi
i will want use ajax call in fiddle, but it's always a problem (with sencha!!! never is simple!!!! :s)

i create a json file in finddle (data1.json)

when i use the proxy object the json it' always not found



Ext.define('Myapp.store.DqlStore', {
extend: 'Ext.data.TreeStore',

model: 'Myapp.model.tree.Dql',

proxy: {
type: 'ajax',
reader: {
type: 'json',
typeProperty: 'mtype'
},
url: 'Mock Data/data1.json' //not found
// url: 'Mock Data\data1.json' //not found
// url: 'data1.json' //not found
// url: './data1.json' //not found
// url: '/data1.json' //not found



},

parentIdProperty: 'parentId'
// lazyFill: false
});


simple is another world for sencha :-?:)):))

why when i run the fiddle the network don't call every time the ajax file???there is some setting?

evant
1 Feb 2016, 1:06 PM
Why didn't you post your fiddle? Works fine for me:

14u9

lbottoni
2 Feb 2016, 1:38 AM
thanks, some help in fiddle is not bad idea :>

mitchellsimoens
2 Feb 2016, 6:52 AM
thanks, some help in fiddle is not bad idea :>

If you have some specific feedback I'd be glad to hear it. Not sure how much easier mock data can be but open to suggestions if you have any.

jhane.mawnee
2 Feb 2016, 8:12 PM
got the same problem. thanks for this post!

marc.fearby
11 Jul 2016, 7:43 PM
I just had a similar problem and it turns out that if you delete the Ext.application({...}) starter fiddle template and just define things and render to Ext.getBody() yourself then the data1.json can't be found. As soon as I created my store within the launch() function it was able to find data1.json.

Perhaps the template could be this?


Ext.application({
name : 'Fiddle',

launch : function() {
Ext.Msg.alert('Fiddle', 'Welcome to Sencha Fiddle! Define your stores here or else they won't find the mock data!');
}
});


Unless, of course, I was doing something else wrong and putting my code in the launch() function was unrelated to whatever else I might have done to solve my problem?

mitchellsimoens
12 Jul 2016, 7:14 AM
The reason for having to wait for launch (or Ext.onReady) is because it has to load the ajax simulator classes which use Ext.require. The assets are then added to the SimManager class within an Ext.onReady block (simple inspection of the iframe would show this):

54793

So if your code doesn't wait for that, then it won't yet be registered.

Things in fiddle 2 have changed quite a bit including the fact that there is no data simulation, it's real network calls.