Yes, as usual, if you want to prevent escaping in the view, you must wrap
with XML(). Another options is:
Controller:
return dict(stra='abcd', obj=alist) # No JSON conversion needed here.
View:
<script>
{{=ASSIGNJS(o=obj)}}
...
The ASSIGNJS helper will handle everything.
Anthony
On Friday, July 28, 2017 at 3:56:45 PM UTC-4, Pierre wrote:
>
> Yes I want to execute a view here is the example code:
>
> Controller:
>
> from json import dumps as jdumps
>
> def abtest():
> alist = ["it's ok","I'm late"]
> return dict(stra='abcd', obj=jdumps(alist))
>
> View:
>
> {{extend 'layout.html'}}
> <h1>Ceci est le modèle test/abtest.html </h1>
> <h1 id='result'>
> RESULT
> </h1>
> <script>
> var o= "{{=obj}}";
> var po = JSON.parse(o);
> console.log(po);
> jQuery("#result").html(po);
> </script>
>
>
> JSON decode error:
>
> SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the
> JSON data
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.