PHP small white, want to implement the File_get_content () read the text content, displayed in the Bootstrap modal box, do not know how to achieve.
First of all, before the post has been Google Baidu, did not solve. Finally focus on, how to click ViewAfter this button, this parameter is $p (where $p =). /web/test.php) is passed to File_get_contment (), and then the contents returned by File_get_content () are passed to the modal box for display.
Click the button here and view it in the modal box
New, know the code has a lot of nonstandard, do not spray
Reply to discussion (solution)
Use Ajax: Because the. php file is interpreted in Apache or nginx, it interprets the inside, then translates it into an HTML file, which is sent to the browser and the user clicks on the button on the client to trigger the file_get_ Contents is not possible unless you have previously obtained and hidden the contents of file_get_contents (Display:none;) and then clicked the button again Display:block, or when you clicked on the button, Send AJAX requests to get file_get_contents content display, of course, refresh the page is also possible.
Use Ajax: Because the. php file is interpreted in Apache or nginx, it interprets the inside, then translates it into an HTML file, which is sent to the browser and the user clicks on the button on the client to trigger the file_get_ Contents is not possible unless you have previously obtained and hidden the contents of file_get_contents (Display:none;) and then clicked the button again Display:block, or when you clicked on the button, Send AJAX requests to get file_get_contents content display, of course, refresh the page is also possible.
Before posting, try Ajax, put $p = ". /web/index.php "This path file name, after uploading to the background, with File_get_content () to get the content, whether to return in JSON format, before the trial, in JSON format returned, did not succeed. So the question at two points;
Back in the background
Echo Json_decode (File_get_content ($p));
Front desk, Ajax settings datatype: ' JSON '
I've tried it.
Above, thank you for your answer
This has no direct relationship with File_get_content ().
1, since the page uses BootStrap, then he is using AJAX to exchange information with the server
You can return the content he sent to determine if the bootStrap is normal.
2. Determine if the file_get_content () result is normal
Echo file_get_content (Submitted path)
Simply simulate the implementation in PHP, regardless of the client
3, only when the last two checks are correct, you also need to check the data format is correct
File_get_contents just gets the data, but finally it needs JS to put the acquired data into the bootstrap. So it has nothing to do with file_get_contents.
Should look at what is returned.
File_get_contents just gets the data, but finally it needs JS to put the acquired data into the bootstrap. So it has nothing to do with file_get_contents.
Should look at what is returned.
Encounter a strange little problem, after the Ajax returned data, alert can be displayed, if placed in the input tag, there are values, but placed in the DIV tag is not, not complex, just a few lines of code, but do not understand why Div can not display the content
This is backstage.
This is Javascipt's function.
This is the notation inside the modal box.
This is the result of the operation
Wondering why Div can't show the content returned by Ajax
File_get_contents just gets the data, but finally it needs JS to put the acquired data into the bootstrap. So it has nothing to do with file_get_contents.
Should look at what is returned.
This has no direct relationship with File_get_content ().
1, since the page uses BootStrap, then he is using AJAX to exchange information with the server
You can return the content he sent to determine if the bootStrap is normal.
2. Determine if the file_get_content () result is normal
Echo file_get_content (Submitted path)
Simply simulate the implementation in PHP, regardless of the client
3, only when the last two checks are correct, you also need to check the data format is correct
Look at the 5 floor of a small problem, Ajax returned data can not be displayed, thank you very much
Use Ajax: Because the. php file is interpreted in Apache or nginx, it interprets the inside, then translates it into an HTML file, which is sent to the browser and the user clicks on the button on the client to trigger the file_get_ Contents is not possible unless you have previously obtained and hidden the contents of file_get_contents (Display:none;) and then clicked the button again Display:block, or when you clicked on the button, Send AJAX requests to get file_get_contents content display, of course, refresh the page is also possible.
In the continuation of the process, encountered a small problem, on the 5 floor, to help look under, thank you very much
Because the JSON data is returned from the background, you use $.ajax, and you specify that the data type is JSON and will of course be parsed into a JSON object. Yes, it's a JSON object, not a string.
So you either change the specified data type Datatype:text or datatype:html
Or turn the data into a JSON string
Json.stringify (msg)
The data you get is PHP code that can be displayed in text mode
Otherwise the browser will
PHP code should be put in, otherwise it will not be parsed as HTML code.
To do a summary, back in the background data, is the JSON format, in the Modal box, with textarea this label can be displayed.
Thank you, upstairs.