if I had several websites and I would want to read “file.html” in every website, how should I do that? The file.html would be just like this:
<h1>Hot news</h1>
<p>article</p>
I know I can use php include or require,
<? include 'file.html'; ?>
or jQuery, but only within a domain.
.load("file.html");
How should I do that cross-domain?
PS: And yes, I know that’s insecure
You can use PHP for it:
The reason why
includedoesn’t work is that url includes are disabled by default since they are horribly insecure – the included document is handled as PHP. However, withfile_get_contentsno PHP code can be injected and thus it’s pretty safe (except client-side things such as XSS if the remote site sends you bad JavaScript code).