/    Sign up×
Community /Pin to ProfileBookmark

How To Open File And Load Contents Into A Variable

Hi,

in my PHP webpage I specify 3 files, like:

[CODE]
$first_file = $_POST[“one”];
$second_file = $_POST[“two”];
$third_file = $_POST[“three”];
[/CODE]

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:

[CODE]
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
]
}
]
[/CODE]

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!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@TcobbDec 09.2012 — This is not very clear. Where are these files located? I get the impression that they are on the server, then sent to the user embedded in the javascript, and then the data is modified by the user and sent back to the server. Is this correct?
×

Success!

Help @ktsirig spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...