Guys,
I have been working on a script that can be placed on any of our clients websites.
It is a mix of PHP and Javascript.
The way it works is:
on any of our customer's website pages they will have a reference (like the one below).
Code:
<script src="http://www.test.com/script.php"></script>
it calls the php script on my server which takes their request, processes it and provides a file ready to be read on my server. This file will be in multiple formats depending on how we have confirmed with the customer so it could be xml , html, csv etc.
The problem I am having is that I have used PHP's file_get_contents function to obtain the html of the file this script creates however when i try to write the contents out to the screen using javascript I get errors.
Code:
<?php
$CONTENTS= file_get_contents("www.test.com/generated_file.html");
?>
Code:
document.getElementById("MyDivName").innerHTML = "<?=$CONTENTS?>";
Because the data stored in $CONTENTS can be any format and contain single and double quotes I am getting the 'unterminated string literal' on the above line.
Has anyone ever come across this issue and does anyone have any advice on how to actually take the contents of the file (stored on an external website) and displaying it?
I;m not that versed with Javascript so hopefully it may be an easy solution / function that already exists?
Thanks
Ed