homepage Welcome to WebmasterWorld Guest from 54.198.42.105
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
How To Open File And Load Contents Into A Variable
ktsirig




msg:4526213
 12:44 am on Dec 9, 2012 (gmt 0)

Hi,

in my PHP webpage I specify 3 files, like:


$first_file = $_POST["one"];
$second_file = $_POST["two"];
$third_file = $_POST["three"];


then I have a JS fuction, that in some points, needs to open each file and store the data of each file into a variable. My questions are 2:
First, how do I save all data of each text file into a JS variable?
Second, the part of the Js function which has these variables looks like this:


series:
[
{
name: 'ONE',
color: 'blue',
data:
[
HERE WE SHOULD PLACE ALL DATA FROM FILE 1
]
},

{
name: 'TWO',
color: 'yellow',
data:
[
HERE WE SHOULD PLACE ALL DATA FROM FILE 2
]
},

{
name: 'THREE',
color: 'red',
data:
[
HERE WE SHOULD PLACE ALL DATA FROM FILE 3
]
}
]


Can you please help me, how I can put the data of each file into the correct place? I am new to JS and came across a helpful snipet of code, but I do not know how I can place my data inside the JS code so as to use them.

Thanks a lot!

 

swa66




msg:4526296
 12:31 pm on Dec 9, 2012 (gmt 0)

You're leaving out some crucial info.

Where are the files stored ? (server? Accessible via the web (i.e. does it have e.g. a URL)? , client? )
When do you want the contents to be loaded ? "at some point" suggests that you want to wait, ...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved