[web2py] Re: work with JSON string

2019-02-04 Thread Константин Комков
 Dave S, I parsed that JSON string in Python and didn't have error. As I 
think problem is in next string: 

> data: 'data='+JSON.stringify(data),

but I don't know how to see data in that moment. Now I solve it changing 
(;) symbol.

> var transfotmStr = $('#problem_input').val().split(';').join(',');
>

-- 
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/d/optout.


[web2py] Re: work with JSON string

2019-01-24 Thread Dave S


On Tuesday, January 22, 2019 at 5:19:34 AM UTC-8, Константин Комков wrote:
>
> I have JS object which was coverted to JSON string.
> JS:
> data = {
> email:$('#email').val(),
> phone:$('#phone').val(),
> docs:$('#studDoc option:selected').text(),
> quantity:$('#quantity').val(),
> organization:$('#organization').val(),
> dateS:$('#dateStart').val(),
> dateE:$('#dateEnd').val(),
> mailing:$('#mailing').prop('checked'),
> socialLink:$('#socialLink').val()
> };
> jQuery.ajax({
> type: "POST",
> url: "stud_request",
> data: 'data='+JSON.stringify(data),
> cache: false,
> success: function(data) {
> deleteOrders();
> $('#results').html(data);
> $('.cssload-loader').hide();},
> error: function(data){
> console.log("error");
> console.log(data);
> $('.cssload-loader').hide();
> }
> Then I get it in controller.
> Python:
> def stud_request():
> import json
> a = json.loads(request.vars.data)
> It's what I can see in console JS
> JSON string
> {"email":"","phone":"8-999-99-99-999; 8-999-99-99-999","docs":"Creating 
> email","quantity":"1","organization":"","dateS":"","dateE":"","mailing":false,"socialLink":""}
> In web2py ticket I see that string be interrupted
> (Unterminated string starting at: line 1 
> column 21 (char 20))
> Function argument list
>
> (self=, 
> s='{"email":"","phone":"8-999-99-99-999', idx=0)
>
>
> My questin is why *;* symbol causes error (as I know it's not special 
> JSON symbol)?
>
>

-- 
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/d/optout.