iwato Posted May 31, 2018 Share Posted May 31, 2018 BACKGROUND: I have a plain text file with an .html extension. In the file is a <p> element into which I would like to enter the current date. The file is called from its hostpage via a jQuery $.get() statement that is followed with an AJAX call to a PHP processing file that returns JSON that can be processed in the AJAX success function as an object. QUESTION: If I place the PHP necessary to create the date in the text file with the .html extension, will it appear in the hostpage when called by the $.get() method? NOTE: My server is programmed to accept PHP in files with a .html extension. Mind you, the text file has neither <head>, nor <body> element, let alone a <DOC> header. Roddy If I enter the data with PHP before the AJAX Link to comment Share on other sites More sharing options...
justsomeguy Posted May 31, 2018 Share Posted May 31, 2018 If I place the PHP necessary to create the date in the text file with the .html extension, will it appear in the hostpage when called by the $.get() method? Is your server configured to send .html files to PHP? If so, then yes. If not, then no. Link to comment Share on other sites More sharing options...
iwato Posted June 1, 2018 Author Share Posted June 1, 2018 It is configured, but the file in question does not respond as hoped. <?php echo date("r"); ?> Roddy Link to comment Share on other sites More sharing options...
justsomeguy Posted June 1, 2018 Share Posted June 1, 2018 And how exactly does it respond? The basics are pretty simple: if the web server receives a request for a certain URL, and it has been configured to handle that URL with PHP, then it will. If it's not, then one of the assumptions you've made is not correct. Maybe it's not configured correctly, maybe there's an .htaccess file telling it to do something else, etc. Link to comment Share on other sites More sharing options...
iwato Posted June 2, 2018 Author Share Posted June 2, 2018 Recently my hostserver modified their system and notified me of an .htaccess file that they placed on my website so that my HTML files could handle PHP. I opened and examined it, but saw nothing out of the ordinary. In fact, it appears very similar to what I use to use on my own test server before my hard disk failure. The file's permissions are 644. Might the problem be related to the absence of header tags? Once again, the file is little more than a text file with an .html extension. The document begins and ends with the same <div> element. Roddy Link to comment Share on other sites More sharing options...
iwato Posted June 2, 2018 Author Share Posted June 2, 2018 By changing the file's extension from .html to .php and then using the $.get() method to call it in its modified format the problem was resolved. Unfortunately, I am still confused as to why this modification was necessary, when I have other files with the HTML extension that have no trouble processing PHP. Roddy Link to comment Share on other sites More sharing options...
justsomeguy Posted June 4, 2018 Share Posted June 4, 2018 If that is controlled by .htaccess then it's dependent on the location of that file. Files in different directories may behave differently if the rules in .htaccess say that. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now