Jump to content

How To Open File And Load Contents Into A Variable


ktsirig

Recommended Posts

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.