PDA

View Full Version : MVC Tutorial - Can't Update JSON file



dkahl
22 Oct 2012, 10:50 AM
I'm in process of going through the MVC tutorial.

The first problem I had was not being able to read the users.json file. It was an IIS MIME issue. I'd recommend adding "how to" information to the tutorial about IIS if users encounter the 404.3 error; I think that was the code.

The current problem I'm having is trying to create the updatedUsers.json file, which is in the last part of the MVC tutorial. Here's what I'm getting:

Request URL:
http://localhost/ExtJS/AcctMgr/data/updatedUsers.json?_dc=1350926811829
Request Method:
POST
Status Code:
http://www.sencha.com/forum/chrome-devtools://devtools/Images/errorRedDot.png 404 Not Found

I tried creating an empty updatedUsers.json file, but that didn't help.

Thanks,
Daryl

vietits
22 Oct 2012, 4:15 PM
You should add a "text/javascript" MIME Type for ".json" extension to IIS Manager.

dkahl
24 Oct 2012, 2:02 PM
I had previously added ".json" to IIS' MIME types as "application/json", which allowed me to read a ".json" file. Did you mean to add as "application/javascript" rather than "application/json"?

vietits
24 Oct 2012, 3:41 PM
What is your updateUsers.json? Does it exist? Is it a static json or a server script that returns json data?

dkahl
25 Oct 2012, 6:52 AM
What is your updateUsers.json? Does it exist? Is it a static json or a server script that returns json data?

Initially, it didn't exist. I expected the code in the tutotial would cause the file to be created if it didn't exist. The file wasn't created. I tried creating an empty file, but that didn't help.

The tutorial can be found at:
http://docs.sencha.com/ext-js/4-1/#!/guide/application_architecture

The relevant code is toward the end of the tutorial, in section "Saving to the server".

vietits
25 Oct 2012, 4:14 PM
Oh, it seems you misunderstand the ability of Ext. It only can generate request to server and it's the role of server script to do all the rest. For successfully sending request to server, all urls must be available.

With your case, updateUsers.json does not exist, so it will cause error "404 not found". BTW, most of the cases, request url are often server script (such as PHP, ASP.NET...) to handle the request, not static data file.

dkahl
26 Oct 2012, 10:58 AM
Oh, it seems you misunderstand the ability of Ext. It only can generate request to server and it's the role of server script to do all the rest. For successfully sending request to server, all urls must be available.

With your case, updateUsers.json does not exist, so it will cause error "404 not found". BTW, most of the cases, request url are often server script (such as PHP, ASP.NET...) to handle the request, not static data file.

Being quite new to Sencha, I have no doubt that I don't fully understand the abilities of Ext. :">

That said, if Ext is a JavaScript object isn't it sending requests to browser not server? As I mentioned, the users.json exists in the same folder where updateUsers.json exists. My tutorial application reads the users.json file from my local C: drive folder. For updating the updateUsers.json file in the same folder, I don't understand why a server would be involved. I am running IIS on my PC so I guess you could make a case that there is a (local) server involved.

Thanks, Daryl

vietits
26 Oct 2012, 6:30 PM
Server I mentioned here is web server. It can be IIS, Apache, etc. It can be on the same PC you are using or on an other computer. As you said, you are using IIS, that's OK.

To handle updating request, you should use a script not a static data file.