PDA

View Full Version : Uncaught Error: [Ext.Loader] Failed loading synchronously via XHR: (When i add store)



kasios
19 Feb 2013, 4:21 PM
I take this error when I add my store to the application (MVC):
W: [Ext.Loader] Synchronously loading 'BTOnline.store.frmBrowserTree'; consider adding Ext.require('BTOnline.store.frmBrowserTree') above Ext.onReady ext-dev.js:8182 (file:///C:/btonline/ext/ext-dev.js)
E: XMLHttpRequest cannot load file:///C:/btonline/app/store/frmBrowserTree.js?_dc=1361314901236. Cross origin requests are only supported for HTTP.
E: Uncaught Error: [Ext.Loader] Failed loading synchronously via XHR: 'app/store/frmBrowserTree.js'; It's likely that the file is either being loaded from a different domain or from the local file system whereby cross origin requests are not allowed due to security reasons. Use asynchronous loading with Ext.require instead.

Here is the code:

app.js

Ext.application({
requires: [
'BTOnline.view.frmBrowser'
],
//Nombre de la aplicación.
name: 'BTOnline',
models: ['frmBrowserTree'],
stores: ['frmBrowserTree'], //i take the error when i add this line
controllers: ['frmBrowserTree'],


/*Cargamos un viewport inicial con todas las views*/
launch: function() {
Ext.create('BTOnline.view.frmBrowser');
}
});


stores.js

Ext.define('BTOnline.store.frmBrowserTree', {
extend: 'Ext.data.TreeStore',
requires: 'BTOnline.model.frmBrowserTree',
model: 'frmBrowserTree',


autoLoad: true,
proxy: {
type: 'ajax',
url: 'treeData.json',
}
});

model.js

Ext.define('BTOnline.model.frmBrowserTree', {
extend: 'Ext.data.Model',
fields: [{
name: 'text',
type: 'string'
}]
});

help me, please!!! :/

scottmartin
20 Feb 2013, 1:54 PM
Try something like:

// store


Ext.define('BTOnline.store.frmBrowserTree', {
extend: 'Ext.data.TreeStore',
model: 'BTOnline.model.frmBrowserTree',
..
});


// app.js


Ext.application({
name : 'BTOnline',

models : ['frmBrowserTree'],
stores : ['frmBrowserTree'],

launch: function() { }

autoCreateViewport : true, // load viewport

controllers : ['frmBrowserTree'] // load controller;

});


// controller


Ext.define('BTOnline.controller.frmBrowserTree', {
extend : 'Ext.app.Controller',

stores : [ 'frmBrowserTree' ],
models : [ 'frmBrowserTree' ],

views : [
'frmBrowser'
],

..

});


Scott.

kasios
20 Feb 2013, 3:20 PM
Thx scott! but it still doesnt work. :( (Same error)

Now i have this:
(more info)

app.js

Ext.application({ name: 'BTOnline',
models: ['frmBrowserTree'],
stores: ['frmBrowserTree'], //Break loading this line :(
autoCreateViewport : true,
controllers: ['frmBrowserTree']
});

model.frmBrowserTree

Ext.define('BTOnline.model.frmBrowserTree', { extend: 'Ext.data.Model',
fields: [{
name: 'text',
type: 'string'
}]
});

store.frmBrowserTree

Ext.define('BTOnline.store.frmBrowserTree', { extend: 'Ext.data.TreeStore',
model: 'frmBrowserTree',
//autoLoad: true,
proxy: {
type: 'ajax',
url: 'treeData.json'
}
});

controller.frmBrowserTree

Ext.define('BTOnline.controller.frmBrowserTree', { extend: 'Ext.app.Controller',
stores : ['frmBrowserTree'],
models : ['frmBrowserTree'],
views: ['frmBrowserTree'],


init: function() {
console.log('Loaded: frmBrowserTree');
}
});

treeData.json (I copied it in the forum, and the model too)

{ text: '.',
children: [{
text:'Basic Ext Layouts',
expanded: true,
children:[{
text:'Absolute',
id:'absolute',
leaf:true
},{
text:'Accordion',
id:'accordion',
leaf:true
},{
text:'Anchor',
id:'anchor',
leaf:true
},{
text:'Border',
id:'border',
leaf:true
},{
text:'Card (TabPanel)',
id:'card-tabs',
leaf:true
},{
text:'Card (Wizard)',
id:'card-wizard',
leaf:true
},{
text:'Column',
id:'column',
leaf:true
},{
text:'Fit',
id:'fit',
leaf:true
},{
text:'Table',
id:'table',
leaf:true
},{
text:'vBox',
id:'vbox',
leaf:true
},{
text:'hBox',
id:'hbox',
leaf:true
}]
},{
text:'Custom Layouts',
children:[{
text:'Center',
id:'center',
leaf:true
}]
},{
text:'Combination Examples',
children:[{
text:'Absolute Layout Form',
id:'abs-form',
leaf:true
},{
text:'Tabs with Nested Layouts',
id:'tabs-nested-layouts',
leaf:true
}]
}]
}

My viewport calls an accordion that calls the TreeView. It works without loading the store in app.js.
I still I have my TreeView without loading my store: (i thought it couldnt be the problem)

Ext.define('BTOnline.view.frmBrowserTree', {/*Arbol de proyectos que está contenido por el acordeon izquierdo
en el browser*/
extend: 'Ext.tree.Panel',
alias: 'widget.frmBrowserTree',

id: 'browserTree',
title: 'Browser',
});

I need help!! I'm doing my final year project in my university with exjs!

And thx, scott! :D

gkohen
28 Feb 2014, 9:19 AM
Are you running this from your local disk? Is would be interesting to see your JS include directive .
I had the same case where I had dynamic loading on, running my page locally and trying to load Sencha's classes dynamically from the CDN.