ktsirig Posted December 9, 2012 Share Posted December 9, 2012 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 https://forums.phpfreaks.com/topic/271769-how-to-open-file-and-load-contents-into-a-variable/ Share on other sites More sharing options...
codefossa Posted December 9, 2012 Share Posted December 9, 2012 Check out Ajax and jQuery makes it so much easier. I don't have time to link to a bunch at the moment but check out $.post() and $.load(). Link to comment https://forums.phpfreaks.com/topic/271769-how-to-open-file-and-load-contents-into-a-variable/#findComment-1398302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.