Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 6th, 2009, 05:50 PM
Authorized User
 
Join Date: Aug 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Question An extensionless file is not seen by the .js file

Hi all. I am using a pre-written JavaScript file that creates some pre-designed look and feel for an intranet site. The top bar navigation is determined by another file that is extensionless named "site_data" that has a certain schema that the .js uses to created the buttons. So, in essence, I would manipulate this "site_data" file to have this prewritten JavaScript file create the number of buttons and the page title.

Now, I tested these files locally quite a bit and everything worked great. Once I sent the files up to the production server, however, the navigation fails to populate with the buttons.

I checked for differences between the IIS properties between my machine and the production server and the settings are identical (as far as I can tell), but the production server is IIS 6 whereas I am IIS 5.1 locally.

I troubleshot locally by removing this site_data file and reloaded the page locally and got the same results as what is happening on the production server. I have also run the page under Firebug and it sees this "site_data" file and can show the contents, but obviously the JavaScript file just fails to do anything with it. All of the other functions this JavaScript file does apparently work correctly because everything else is done correctly.

Now, obviously I am not looking for a complete solution, but I am looking for a good idea, hint and/or possible course of action to solve this problem. I admit to being a little more ignorant in this area than I care to be, but I'm starting to suspect this is more than just a simple mis-location problem or other nuanced problem.

I would provide code for example, but unfortunately I cannot display it since it is company code and I am unallowed to show it. So sorry about this.

I thank any and all help ahead of time.
 
Old May 6th, 2009, 06:30 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Okay, I give up. Why not just change the file name to "site_data.js" if you think the lack of extension is the problem?

And you know, even if you can't show actual files because of company policy, *surely* you could make up parallel example files to test your theories and code and to show to us.
 
Old May 7th, 2009, 12:50 AM
Authorized User
 
Join Date: Aug 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Old Pedant View Post
Okay, I give up. Why not just change the file name to "site_data.js" if you think the lack of extension is the problem?

And you know, even if you can't show actual files because of company policy, *surely* you could make up parallel example files to test your theories and code and to show to us.
You would think that would be the easiest solution, but unfortunately adding the extension actually stops it from working even on my local machine. I cannot change the .js file either since it resides remotely.

I was studying the "site_data" and the .js file after I posted originally and learned a few more things about this issue.

I'll attempt to do the abstract as you request.
Here is an example of the site_data file:
Code:
_page.items["0] = new Item("Home", "Default.aspx");
_page.items["1"] = new Item("Section1", "section1.aspx");
That is what i have "physical" access to and I can change those values and keep that in the same directory as those files.

And then within the .js file, there exists code that defines what each Item is, which is then used in a _pageStart function that is called at the top of the body element. I do not know enough JavaScript to follow the code very well and how each function in a .js file works with each other, so it becomes lost on me to know how the .js file interacts with the site_data file when it's not declared within the .js and how the site_data file executes if it is never known by any other files. Thus, if I could figure out how that happens and works, I could probably figure out my problem.

Any takers?
 
Old May 7th, 2009, 04:20 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Quote:
I cannot change the .js file either since it resides remotely.
I assume by that you mean the .js file that in turn uses your site_data file, yes?

Ugh.

Can you at least show whatever code in the ".js" file makes the reference to the site_data file???

That is, does it somehow load the file? Via AJAX or something? I'm a little suprised that it even knows the name of the site_date file.
 
Old May 7th, 2009, 05:00 PM
Authorized User
 
Join Date: Aug 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Old Pedant View Post
I assume by that you mean the .js file that in turn uses your site_data file, yes?

Ugh.

Can you at least show whatever code in the ".js" file makes the reference to the site_data file???
I apologize. I am being difficult here. But yes, the lib.js file (the one I have been referencing before and I'm sorry I didn't use it's official name but I'm starting to get a little more desperate for a fix) uses the site_data file to create the buttons.
That Item function I mentioned earlier is like this:
Code:
/* menu item constructor */
function _Item(text, link) {
   this.text=text; 
   if(link=="") {
  this.link="#";
   } else {
  this.link=link;
   }
Quote:
That is, does it somehow load the file? Via AJAX or something? I'm a little suprised that it even knows the name of the site_date file.
This is the part that doesn't make sense for me either! I looked through all the code and even did quick finds to find any variations of site_data in it to find it to no avail.

I managed to get ahold of the intranet people, the ones who designed this and the best they could offer as advice is that when they did http://(URL)/site_data it gave a 404 error, despite the file existing in the directory. I know it is there, I put it there 3 times in some crazy thinking that it was never truly there. But it is! And then when i tested that locally, I had the site_data file open in teh browser.

I'm beginning to think this isn't a JavaScript problem but a file problem. Something like my production server doesn't allow extensionless files to be used or something stupid like that.

Unless anybody has any hints along that line, I just want to thank Old Pendant for making an attempt to help. Off to try another line of troubleshooting...
 
Old May 7th, 2009, 06:13 PM
Authorized User
 
Join Date: Aug 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Just so you know, I found the solution.

I talked to another group that uses the same look and feel, with the pre-written javascript files (which were written by the global intranet team, wherever they are) and I saw that they renamed this "site_data" file to include a .txt extension. I did the same, altered the include in my masterpage to reflect this and WAHLAH! It works now.

WHY?? I DO NOT KNOW!!!

Anyways...thanks again for the attempt at help.
 
Old May 7th, 2009, 08:12 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Weirder than weird. Well, whatever it takes!
The Following User Says Thank You to Old Pedant For This Useful Post:
overcast (May 7th, 2009)
 
Old May 8th, 2009, 03:29 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Arrived a bit late to the party but I would have tried Fiddler or the like to see what happened to the request.
Maybe the folder had a default document set, anyway the address http://mysite.com/site_data looks like a folder rather than a file so the server may have looked for that folder and not found it.
Another possibility is mime-type, I don't see how you set one for an extensionless file so maybe that affected fetching it.
__________________
Joe
http://joe.fawcett.name/





Similar Threads
Thread Thread Starter Forum Replies Last Post
To include a js file into another js file jdang67 Javascript 4 February 28th, 2008 03:32 AM
asp file into a javascript file (js)? jstewie Javascript How-To 2 August 25th, 2005 08:32 AM
convert a js file from a asp file - change format jstewie Javascript How-To 0 July 21st, 2005 08:57 AM
.js file question savoym Javascript How-To 1 May 17th, 2004 02:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.