PDA

View Full Version : I have a problem with MVC Architecture - Saving to the server...



newtoextjs4
12 Sep 2012, 8:57 AM
As a brand new user of 'extjs,' I decided to go through the chapters of 'Ext JS 4.1 Sencha Docs' one by one in order to familiarize myself with the environment.

First, on a brand new XP virtual machine, I installed FireFox 15 with the Firebug Web Development Plugin. I also installed Opera 12 and Google Chrome 21+. Then I installed Apache on Windows followed by the latest mySQL. Finally, I added Ext JS 4 SDK to my machine.

When I read the 'MVC Architecture' chapter, I was able to successfully implement the examples up to the 'Saving to the server' sub-chapter. When I try to execute the code found below, I get the following error on Opera: "Unhandled DOMException: NETWORK_ERR.

Ext.define('AM.store.Users', {


extend: 'Ext.data.Store',


model: 'AM.model.User',


autoLoad: true,


proxy: {


type: 'ajax',


url: 'data/users.json',


reader: {


type: 'json',


root: 'users',


successProperty: 'success'


}


}


});



As a brand new web developer and 'extjs' user, I am kind of stuck. Does anyone know what my be the problem and how to solve it? Is it the 'url?'

scottmartin
12 Sep 2012, 10:09 AM
At what point in your code do you see this? Have you setup a breakpoint or do you have a callstack?

If you enter the URL in our browser, does it reply back with a response?
: localhost/app/data/users.json <- adjust to your url

Scott.

scottmartin
12 Sep 2012, 10:10 AM
Also .. you mention 'Saving to the Server', but you are referencing a JSON file. Are you saving to a table MySQL?

Scott.

newtoextjs4
12 Sep 2012, 11:06 AM
When I enter the following URL ("localhost/account manager/data/users.json") in my Opera browser, I am asked if I want to download the file.

scottmartin
12 Sep 2012, 11:13 AM
If you say yes, what do you get ... I am not familiar with Opera.. what if you use Chrome of FF?
It should just spit the JSON to the body.

Scott

newtoextjs4
12 Sep 2012, 11:18 AM
The 'Saving to the Server' reference is related to the header found within the particular 'Ext JS 4.1 Sencha Docs' that I am currently reading: 'MVC Application Architecture (http://docs.sencha.com/ext-js/4-1/#!/guide/application_architecture).'

Here what is found under 'Saving to the server'

Easy enough. Let's finish this up now by making it interact with our server side. At the moment we are hard coding the two User records into the Users Store, so let's start by reading those over AJAX instead.

newtoextjs4
13 Sep 2012, 9:27 AM
Sorry for the late reply, I missed your "what if you use Chrome or FF" question.

Per your suggestion, I entered the "localhost/account manager/data/users.json" URL in both Chrome and FF. With both browsers, the result was a display of the 'json' file content onto the body. Apparently there is a problem with Opera but as long as everything works with Chrome or FF, I am OK with it.

This result prompted me to slightly modify the 'url' property of my 'proxy' from:
url: 'account manager/data/users.json',

to:
url: 'http://localhost/account manager/data/users.json',


With this modification, everything works as expected. Thanks for your help and pointing me in the right direction.

Being new to web programming and 'extjs,' I had not realized that the 'url' property needed a 'full' path (including 'http://localhost/').