JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 20th, 2010, 07:18 AM
edfollett's Avatar
edfollett edfollett is offline
guru
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: SW1A London UK
Posts: 608 edfollett Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 3 Days 12 h 30 m 38 sec
Reputation Power: 0
Problem reading and displaying string in innerhtml.

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
__________________
Create, Inspire & enjoy

Reply With Quote
  #2  
Old March 20th, 2010, 08:05 AM
edfollett's Avatar
edfollett edfollett is offline
guru
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: SW1A London UK
Posts: 608 edfollett Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 3 Days 12 h 30 m 38 sec
Reputation Power: 0
dont worry I worked it out: i added:

Code:
$CONTENTS = addslashes(str_replace("\n","",stripslashes($CONTENTS)));


works a treat

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Problem reading and displaying string in innerhtml.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap