[web2py] Re: Access the server data in javascript

2013-10-28 Thread Derek
If you are just using the column value itself, you probably need to convert 
it to a string before putting it in the json.

Example:

>>> c = long(10)
>>> c
10L
>>> str(c)
'10'


On Saturday, October 26, 2013 8:09:25 AM UTC-7, Ramesh Kumar wrote:
>
> Thanks Derek, but I am facing one more problem. An 'L' gets appended to 
> integer data. When I try to get the dict into a json, I am facing "Uncaught 
> SyntaxError: Unexpected token ILLEGAL " error. Any help on this?
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Access the server data in javascript

2013-10-27 Thread Alan Etkin

>
> Thanks Derek, but I am facing one more problem. An 'L' gets appended to 
> integer data. When I try to get the dict into a json, I am facing "Uncaught 
> SyntaxError: Unexpected token ILLEGAL " error. Any help on this?
>

Many web2py api objects as query results (Rows objects) or forms have an 
.as_json() method, so you don't need to code your own conversion logic:

>>> script = SCRIPT("""var myData = %s;""" % db(...).select().as_json())

Post the code so we can help fixing it.

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Access the server data in javascript

2013-10-26 Thread Ramesh Kumar
Thanks Derek, but I am facing one more problem. An 'L' gets appended to 
integer data. When I try to get the dict into a json, I am facing "Uncaught 
SyntaxError: Unexpected token ILLEGAL " error. Any help on this?

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Access the server data in javascript

2013-10-25 Thread Derek
use {{=XML()}} around things you want to return raw in your views.

On Friday, October 25, 2013 12:23:16 PM UTC-7, Ramesh Kumar wrote:
>
> I want to access the server data in the client side. I am currently ajax 
> calling and returning the data in a dict. I am storing the returned data 
> structure in a javascript variable. When I try to print the data from 
> javascript variable, the console log shows html characters for double 
> quotes. I am using double quotes around the keys in the hash. How to 
> overcome this error?
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.