|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
SteveJ Smarty n00b
Joined: 04 Mar 2016 Posts: 3
|
Posted: Fri May 12, 2017 7:43 pm Post subject: Invalid Character inretrieved string |
|
|
Hello
I'm retrieving an image from an SQL database as a BLOB and using a smarty template to process it. I get an invalid character error when I try to pass the retrived data to a javascript parameter. Essentially this is because the retrieved data contains non printing characters.
Is there any way I can get round this problem?
Code: |
<script>
{literal}
var markers = [
{/literal}{foreach item=Row from=$DataGrid.Rows}{literal}
{
"date": '{/literal}{$Row.DataCells.MapDate.Value}{literal}',
"lat": {/literal}{$Row.DataCells.Latitude.Value}{literal},
"lng": {/literal}{$Row.DataCells.Longitude.Value}{literal},
"image": "{/literal}{$Row.DataCells.Image.Value}{literal}",
"description": "{/literal}{$Row.DataCells.Comments.Value}{literal}",
"type": "{/literal}{$Row.DataCells.Type.Value}{literal}"
},
{/literal}{/foreach}{literal}
];
{/literal}
</script>
|
SteveJ |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat May 13, 2017 1:36 pm Post subject: Re: Invalid Character inretrieved string |
|
|
Escape the string properly. |
|
Back to top |
|
SteveJ Smarty n00b
Joined: 04 Mar 2016 Posts: 3
|
Posted: Sat May 13, 2017 1:59 pm Post subject: Re: Invalid Character inretrieved string |
|
|
AnrDaemon wrote: | Escape the string properly. |
Useful answer for a complete newbie. How?
SteveJ |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat May 13, 2017 4:36 pm Post subject: |
|
|
No idea. Google "javascript string special characters escaping" or something.
This is not a Smarty question, for Smarty, all the data it output is equal and lacks any meaning outside trivial byte stream. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|