Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-18 Thread Vlad
Okay, done :) 
(Assuming that Python code in {{...}} can't access anything from Javascript 
on the page - and here encode URI came into play, as per your earlier 
advice)

var id = $('#CurrentCartId').text();
var description = $(this).text();
var url='{{=URL('cart','description')}}';
url += '/' + id + '/';
url += "?description="+description;
url=encodeURI(url);
ajax(url,[],':eval');


On Saturday, May 18, 2019 at 10:45:02 PM UTC-4, Vlad wrote:
>
> Oops, I still don't know how to achieve it. Here is why: 
>
> This is from the javascript code on the page: 
>
> var description = $(this).text();
> var 
> url='{{=URL('cart','description'),args=[id],vars=[dict(description=description)]}}';
>
> So, the variable description belongs to javascript, and it's presumably 
> impossible to access it in {{...}} sections, unless I am missing something. 
> Any code in {{...}} is executed and built on the server side, and then 
> delivered to the browser, so while on the server, those javascript 
> variables are inaccessible. OR is there a way to somehow access them 
>
> Of this is this case, then I am stuck to having var 
> url='{{=URL('cart','description')}} and then url += description, hence I 
> now have to use encoding/decoding solution... 
>
> Is there a way to solve this without encoding / decoding??? 
>
> On Saturday, May 18, 2019 at 9:55:22 PM UTC-4, Vlad wrote:
>>
>> Here is a test I've just run: 
>>
>> def test():
>> url = URL('cart','test2',args=['a b c 1 3 2 $ % ( ) 
>> !'],vars={'oops':'1 3 5  a s i t ! @ #  $ %'})
>> redirect(url)
>>
>> def test2():
>> str1 = request.args[0]
>> str2 = request.vars['oops']
>> return locals()
>>
>> Here is what it displays as a result: 
>>
>> {{extend 'layout.html'}}
>> {{=str1}}
>> 
>> {{=str2}}
>>
>> a_b_c_1_3_2__ 
>> 1 3 5 a s i t ! @ # $ % 
>>
>> Obviously, this proves that you're right, and my mistake in the beginning 
>> was that I didn't try vars - I simply tried args, and saw right away that 
>> args distorts the string. I mistakenly assumed that vars works the same way 
>> - and didn't even try it. This is how I got into conversion business...  
>>
>> Anyway, thank you very much for all your help and for patience! 
>>
>> On Fri, May 17, 2019 at 7:44 PM Anthony  wrote:
>>
>>> On Friday, May 17, 2019 at 5:17:09 PM UTC-4, Vlad wrote:

 Also, I think it would be nice if URL helper would have ability to 
 handle this, without a need to figure out the encoding/decoding subject... 

>>>
>>> You don't need the encoding -- just put the values in the query string.
>>>
>>> Anthony
>>>
>>> -- 
>>> 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 a topic in the 
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> web2py+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/web2py/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/87ff379a-31a3-40a8-8d00-51d289a58182%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-18 Thread Vlad
Oops, I still don't know how to achieve it. Here is why: 

This is from the javascript code on the page: 

var description = $(this).text();
var 
url='{{=URL('cart','description'),args=[id],vars=[dict(description=description)]}}';

So, the variable description belongs to javascript, and it's presumably 
impossible to access it in {{...}} sections, unless I am missing something. 
Any code in {{...}} is executed and built on the server side, and then 
delivered to the browser, so while on the server, those javascript 
variables are inaccessible. OR is there a way to somehow access them 

Of this is this case, then I am stuck to having var 
url='{{=URL('cart','description')}} and then url += description, hence I 
now have to use encoding/decoding solution... 

Is there a way to solve this without encoding / decoding??? 

On Saturday, May 18, 2019 at 9:55:22 PM UTC-4, Vlad wrote:
>
> Here is a test I've just run: 
>
> def test():
> url = URL('cart','test2',args=['a b c 1 3 2 $ % ( ) 
> !'],vars={'oops':'1 3 5  a s i t ! @ #  $ %'})
> redirect(url)
>
> def test2():
> str1 = request.args[0]
> str2 = request.vars['oops']
> return locals()
>
> Here is what it displays as a result: 
>
> {{extend 'layout.html'}}
> {{=str1}}
> 
> {{=str2}}
>
> a_b_c_1_3_2__ 
> 1 3 5 a s i t ! @ # $ % 
>
> Obviously, this proves that you're right, and my mistake in the beginning 
> was that I didn't try vars - I simply tried args, and saw right away that 
> args distorts the string. I mistakenly assumed that vars works the same way 
> - and didn't even try it. This is how I got into conversion business...  
>
> Anyway, thank you very much for all your help and for patience! 
>
> On Fri, May 17, 2019 at 7:44 PM Anthony  wrote:
>
>> On Friday, May 17, 2019 at 5:17:09 PM UTC-4, Vlad wrote:
>>>
>>> Also, I think it would be nice if URL helper would have ability to 
>>> handle this, without a need to figure out the encoding/decoding subject... 
>>>
>>
>> You don't need the encoding -- just put the values in the query string.
>>
>> Anthony
>>
>> -- 
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f820d967-bbfe-4a24-aab6-c8a80b8cec3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-18 Thread Eliezer (Vlad) Tseytkin
Here is a test I've just run:

def test():
url = URL('cart','test2',args=['a b c 1 3 2 $ % ( ) !'],vars={'oops':'1
3 5  a s i t ! @ #  $ %'})
redirect(url)

def test2():
str1 = request.args[0]
str2 = request.vars['oops']
return locals()

Here is what it displays as a result:

{{extend 'layout.html'}}
{{=str1}}

{{=str2}}

a_b_c_1_3_2__
1 3 5 a s i t ! @ # $ %

Obviously, this proves that you're right, and my mistake in the beginning
was that I didn't try vars - I simply tried args, and saw right away that
args distorts the string. I mistakenly assumed that vars works the same way
- and didn't even try it. This is how I got into conversion business...

Anyway, thank you very much for all your help and for patience!

On Fri, May 17, 2019 at 7:44 PM Anthony  wrote:

> On Friday, May 17, 2019 at 5:17:09 PM UTC-4, Vlad wrote:
>>
>> Also, I think it would be nice if URL helper would have ability to handle
>> this, without a need to figure out the encoding/decoding subject...
>>
>
> You don't need the encoding -- just put the values in the query string.
>
> Anthony
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCBHCoJ-s-GTrAzabWrtj4foNO4gB8ia%3D-SHxeAJanU0rQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Anthony
On Friday, May 17, 2019 at 5:17:09 PM UTC-4, Vlad wrote:
>
> Also, I think it would be nice if URL helper would have ability to handle 
> this, without a need to figure out the encoding/decoding subject... 
>

You don't need the encoding -- just put the values in the query string.

Anthony

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Also, I think it would be nice if URL helper would have ability to handle
this, without a need to figure out the encoding/decoding subject...

On Fri, May 17, 2019, 5:03 PM Eliezer (Vlad) Tseytkin <
westgate6...@gmail.com> wrote:

> Okay, I got it :)
>
> Very embarrassing. There were some prior entries in the database that
> weren't converted to begin with, so when they were pulled over, the
> exception was raised. I totally forgot about them, and on top of that the
> one that caused the trouble was just one character different from the one I
> was testing against, with 49 characters being the same, so it was almost
> unnoticeable visually...
>
> I thought that the conversion malfunctioned, while in fact it simply
> pulled back something else, without me realizing what was going on...
>
> I took a deep breath and patiently went through the whole thing step by
> step and, of course, found it. It's now just perfect. Ended up using atob
> and btoa.
>
> Just a quick question: are atob and btoa consistent and give the same
> results across browsers and operating systems? (If not, I'll use that uri
> thing, if that's hopefully consistent)
>
> On Fri, May 17, 2019, 12:42 PM Anthony  wrote:
>
>> On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>>>
>>> It works almost, but not 100% :)
>>>
>>> with encodeURIComponent :
>>>
>>> abc def (test)
>>> comes back as
>>> abc_def__test_
>>>
>>
>> Please show your exact code. Doesn't sound like you are using the query
>> string.
>>
>> Anthony
>>
>> --
>> 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/d24a071c-77db-40f3-a991-17b0c2705e90%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCAPxd0rUGsKHer0n_VRxqWb0Xu0-3vWDWGJr-UrV44eQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Okay, I got it :)

Very embarrassing. There were some prior entries in the database that
weren't converted to begin with, so when they were pulled over, the
exception was raised. I totally forgot about them, and on top of that the
one that caused the trouble was just one character different from the one I
was testing against, with 49 characters being the same, so it was almost
unnoticeable visually...

I thought that the conversion malfunctioned, while in fact it simply pulled
back something else, without me realizing what was going on...

I took a deep breath and patiently went through the whole thing step by
step and, of course, found it. It's now just perfect. Ended up using atob
and btoa.

Just a quick question: are atob and btoa consistent and give the same
results across browsers and operating systems? (If not, I'll use that uri
thing, if that's hopefully consistent)

On Fri, May 17, 2019, 12:42 PM Anthony  wrote:

> On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>>
>> It works almost, but not 100% :)
>>
>> with encodeURIComponent :
>>
>> abc def (test)
>> comes back as
>> abc_def__test_
>>
>
> Please show your exact code. Doesn't sound like you are using the query
> string.
>
> Anthony
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/d24a071c-77db-40f3-a991-17b0c2705e90%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCBW2M%3DsRyFq5CqxK6sYEc9pco2qOA9tnpWcACLw_WGAwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Anthony
On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>
> It works almost, but not 100% :) 
>
> with encodeURIComponent :
>
> abc def (test)
> comes back as
> abc_def__test_
>

Please show your exact code. Doesn't sound like you are using the query 
string.

Anthony

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d24a071c-77db-40f3-a991-17b0c2705e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
I'll try to simplify it, hoping that I'll figure it out, but it's really 
very puzzling: 

this works perfect: 

var encodedDescription = $("#CurrentCartDescription").text();
$("#CurrentCartDescription").html(atob(encodedDescription));

it decodes it back just exactly from what it was encoded. 
However, the following is messed up: 

$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 var decodedString = atob(hereWeAre);
 console.error(hereWeAre);
 console.error(decodedString); 
});

throws an exception, even for the same very value! 

Will simplify it all now, let's see what comes out...

On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>
> It works almost, but not 100% :) 
>
> with encodeURIComponent :
>
> abc def (test)
> comes back as
> abc_def__test_
>
> a;slkdjf;l -239i4-29i23la'skfj(()))9012?  <>,.  =
> comes back as
> a_slkdjf_l_-239i4-29i23la_skfj_9012__.__=
>
> This wouldn't help me, because I want it to be exactly whatever they enter 
> - 
>
> In contrast, atob and btoa work just perfect, except that in one 
> particular situation is gets messed up by that exception... 
>
> On Friday, May 17, 2019 at 10:17:50 AM UTC-4, Anthony wrote:
>>
>> On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>>>
>>> I have the following javascript in the view: 
>>>
>>> var id = $('#CurrentCartId').text();
>>> var description = $(this).text();
>>> var url='{{=URL('cart','description')}}';
>>> url += '/' + id + '/';
>>> url += description;
>>> ajax(url,[],':eval');
>>>
>>
>> How about putting the variables in the query string:
>>
>> const id = $('#CurrentCartId').text();
>> const description = $(this).text();
>> const url='{{=URL('cart','description')}}';
>> ajax(
>> `${url}?id=${encodeURIComponent(id)}&description=${encodeURIComponent(description)}`
>> , [], ':eval');
>>
>> Then in the controller, access request.vars.id and 
>> request.vars.description.
>>
>> Anthony
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4fc90afb-1e30-439d-b5ba-730df5bb1a34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
It works almost, but not 100% :) 

with encodeURIComponent :

abc def (test)
comes back as
abc_def__test_

a;slkdjf;l -239i4-29i23la'skfj(()))9012?  <>,.  =
comes back as
a_slkdjf_l_-239i4-29i23la_skfj_9012__.__=

This wouldn't help me, because I want it to be exactly whatever they enter 
- 

In contrast, atob and btoa work just perfect, except that in one particular 
situation is gets messed up by that exception... 

On Friday, May 17, 2019 at 10:17:50 AM UTC-4, Anthony wrote:
>
> On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>>
>> I have the following javascript in the view: 
>>
>> var id = $('#CurrentCartId').text();
>> var description = $(this).text();
>> var url='{{=URL('cart','description')}}';
>> url += '/' + id + '/';
>> url += description;
>> ajax(url,[],':eval');
>>
>
> How about putting the variables in the query string:
>
> const id = $('#CurrentCartId').text();
> const description = $(this).text();
> const url='{{=URL('cart','description')}}';
> ajax(
> `${url}?id=${encodeURIComponent(id)}&description=${encodeURIComponent(description)}`
> , [], ':eval');
>
> Then in the controller, access request.vars.id and 
> request.vars.description.
>
> Anthony
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1e9addff-674e-471b-a570-c07d05df96af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Anthony
On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>

How about putting the variables in the query string:

const id = $('#CurrentCartId').text();
const description = $(this).text();
const url='{{=URL('cart','description')}}';
ajax(
`${url}?id=${encodeURIComponent(id)}&description=${encodeURIComponent(description)}`
, [], ':eval');

Then in the controller, access request.vars.id and request.vars.description.

Anthony

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e574b961-7bc2-4dba-86d4-1f231da4d008%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread villas
Make sure that your jQuery loading and browser up to date...

Simplify the page to something like below.  Get that working.  Add back 
your complexity afterwards:

Q29va2llcyBvbmU=


$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 alert(hereWeAre);
 var decodedString = atob(hereWeAre);
 console.log(decodedString); 
});



On Friday, 17 May 2019 13:24:57 UTC+1, Vlad wrote:
>
> Typo: I meant atob
>
> On Fri, May 17, 2019, 8:21 AM Eliezer (Vlad) Tseytkin  > wrote:
>
>> Those are span elements inside  inside in a table. 
>>
>> But the values themselves are fine - I can print them out, and they are 
>> correct. It's only a problem when I try to apply btoa function to it. 
>>
>> On Fri, May 17, 2019, 8:09 AM villas > 
>> wrote:
>>
>>> Hmm, not sure.  
>>> Are you getting the values from  elements?
>>> Try:  
>>>
>>> var hereWeAre = $(this).val();
>>>
>>>
>>> On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:

 I thought so and tried: 

 $(".EncodedDescriptionField").each( function(index, element ){
  var hereWeAre = $(this).text();
  var decodedString = atob(hereWeAre);
  console.error(hereWeAre);
  console.error(decodedString); 
 });

 this brings up an exception: 

 Uncaught DOMException: Failed to execute 'atob' on 'Window': The string 
 to be decoded is not correctly encoded.

 I've also double-checked the values - they are correct. For example, 
 when I replace with the following: 

  var decodedString = atob("Q29va2llcyBvbmU=");

 it decodes just fine, and the string itself I pick right from there - 
 that's the value it has when it throws exception. 

 Have no slightest clue what could possibly go wrong. 


 On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>
> Maybe you need to iterate through the class elements.  See this:
>
> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>
>
>
> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>>
>> Just to clarify: 
>>
>> the following works perfect  for one field by ID (decrypts it back):
>> var encodedDescription = $("#CurrentCartDescription").text()
>> $("#CurrentCartDescription").html(atob(encodedDescription));
>>
>> However, when I try to do it for a bunch of fields at once using 
>> class (instead of id), it doesn't work - doesn't touch the values: 
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> I am sure I am missing something basic... Greatly appreciate 
>> suggestions - 
>>
>> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>>
>>> I had no clue about it - I mean never heard the terms :)
>>>
>>> Thank you very much for point to the direction. After some googling, 
>>> it is almost working. 
>>>
>>> Encoding is just fine (using btoa). 
>>>
>>> When I read it back and want to decode - it's not yet behaving 
>>> right. I'm suspecting my javascript is a problem. 
>>>
>>> There is a bunch of fields which now have encrypted values (class 
>>> 'EncodedDescriptionField'), and I am trying to use the following to 
>>> reclaim 
>>> the original values: 
>>>
>>>
>>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>>
>>> What am I doing wrong? (It doesn't change the values - they remain 
>>> as they are, encrypted)
>>>
>>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:

 Have you considered base64 encoding/decoding?

 quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>
> the reason I use url+= to pass parameters instead of using args in 
> the URL helper is because the parameters are coming from the html 
> itself - 
> they are not known in the controller py. 
>
> now the problem is that it changes the description and I have no 
> way to recover its original value. for example, when description is 
> "askjdf 
> d   dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed 
> string 
> in this case), it comes out as "askjdf_d___dka_lskdj__3838_". 
> Obviously, it needs

Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Typo: I meant atob

On Fri, May 17, 2019, 8:21 AM Eliezer (Vlad) Tseytkin <
westgate6...@gmail.com> wrote:

> Those are span elements inside  inside in a table.
>
> But the values themselves are fine - I can print them out, and they are
> correct. It's only a problem when I try to apply btoa function to it.
>
> On Fri, May 17, 2019, 8:09 AM villas  wrote:
>
>> Hmm, not sure.
>> Are you getting the values from  elements?
>> Try:
>>
>> var hereWeAre = $(this).val();
>>
>>
>> On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:
>>>
>>> I thought so and tried:
>>>
>>> $(".EncodedDescriptionField").each( function(index, element ){
>>>  var hereWeAre = $(this).text();
>>>  var decodedString = atob(hereWeAre);
>>>  console.error(hereWeAre);
>>>  console.error(decodedString);
>>> });
>>>
>>> this brings up an exception:
>>>
>>> Uncaught DOMException: Failed to execute 'atob' on 'Window': The string
>>> to be decoded is not correctly encoded.
>>>
>>> I've also double-checked the values - they are correct. For example,
>>> when I replace with the following:
>>>
>>>  var decodedString = atob("Q29va2llcyBvbmU=");
>>>
>>> it decodes just fine, and the string itself I pick right from there -
>>> that's the value it has when it throws exception.
>>>
>>> Have no slightest clue what could possibly go wrong.
>>>
>>>
>>> On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:

 Maybe you need to iterate through the class elements.  See this:

 https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class



 On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>
> Just to clarify:
>
> the following works perfect  for one field by ID (decrypts it back):
> var encodedDescription = $("#CurrentCartDescription").text()
> $("#CurrentCartDescription").html(atob(encodedDescription));
>
> However, when I try to do it for a bunch of fields at once using class
> (instead of id), it doesn't work - doesn't touch the values:
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> I am sure I am missing something basic... Greatly appreciate
> suggestions -
>
> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>
>> I had no clue about it - I mean never heard the terms :)
>>
>> Thank you very much for point to the direction. After some googling,
>> it is almost working.
>>
>> Encoding is just fine (using btoa).
>>
>> When I read it back and want to decode - it's not yet behaving right.
>> I'm suspecting my javascript is a problem.
>>
>> There is a bunch of fields which now have encrypted values (class
>> 'EncodedDescriptionField'), and I am trying to use the following to 
>> reclaim
>> the original values:
>>
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> What am I doing wrong? (It doesn't change the values - they remain as
>> they are, encrypted)
>>
>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>>
>>> Have you considered base64 encoding/decoding?
>>>
>>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:

 I have the following javascript in the view:

 var id = $('#CurrentCartId').text();
 var description = $(this).text();
 var url='{{=URL('cart','description')}}';
 url += '/' + id + '/';
 url += description;
 ajax(url,[],':eval');

 the reason I use url+= to pass parameters instead of using args in
 the URL helper is because the parameters are coming from the html 
 itself -
 they are not known in the controller py.

 now the problem is that it changes the description and I have no
 way to recover its original value. for example, when description is 
 "askjdf
 d   dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed 
 string
 in this case), it comes out as "askjdf_d___dka_lskdj__3838_".
 Obviously, it needs to do this conversion in order to pass  the 
 parameter,
 but I need to be able to recreate the original string, entered by the 
 user.

 Is there a better way of doing this? I.e. a better way of passing a
 parameter in  a way that it could be "recreated" and stored in the 
 database
 exactly as typed by the user?

>>> --
>> 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 subs

Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Eliezer (Vlad) Tseytkin
Those are span elements inside  inside in a table.

But the values themselves are fine - I can print them out, and they are
correct. It's only a problem when I try to apply btoa function to it.

On Fri, May 17, 2019, 8:09 AM villas  wrote:

> Hmm, not sure.
> Are you getting the values from  elements?
> Try:
>
> var hereWeAre = $(this).val();
>
>
> On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:
>>
>> I thought so and tried:
>>
>> $(".EncodedDescriptionField").each( function(index, element ){
>>  var hereWeAre = $(this).text();
>>  var decodedString = atob(hereWeAre);
>>  console.error(hereWeAre);
>>  console.error(decodedString);
>> });
>>
>> this brings up an exception:
>>
>> Uncaught DOMException: Failed to execute 'atob' on 'Window': The string
>> to be decoded is not correctly encoded.
>>
>> I've also double-checked the values - they are correct. For example, when
>> I replace with the following:
>>
>>  var decodedString = atob("Q29va2llcyBvbmU=");
>>
>> it decodes just fine, and the string itself I pick right from there -
>> that's the value it has when it throws exception.
>>
>> Have no slightest clue what could possibly go wrong.
>>
>>
>> On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>>>
>>> Maybe you need to iterate through the class elements.  See this:
>>>
>>> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>>>
>>>
>>>
>>> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:

 Just to clarify:

 the following works perfect  for one field by ID (decrypts it back):
 var encodedDescription = $("#CurrentCartDescription").text()
 $("#CurrentCartDescription").html(atob(encodedDescription));

 However, when I try to do it for a bunch of fields at once using class
 (instead of id), it doesn't work - doesn't touch the values:

 $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

 I am sure I am missing something basic... Greatly appreciate
 suggestions -

 On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>
> I had no clue about it - I mean never heard the terms :)
>
> Thank you very much for point to the direction. After some googling,
> it is almost working.
>
> Encoding is just fine (using btoa).
>
> When I read it back and want to decode - it's not yet behaving right.
> I'm suspecting my javascript is a problem.
>
> There is a bunch of fields which now have encrypted values (class
> 'EncodedDescriptionField'), and I am trying to use the following to 
> reclaim
> the original values:
>
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> What am I doing wrong? (It doesn't change the values - they remain as
> they are, encrypted)
>
> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>
>> Have you considered base64 encoding/decoding?
>>
>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>>
>>> I have the following javascript in the view:
>>>
>>> var id = $('#CurrentCartId').text();
>>> var description = $(this).text();
>>> var url='{{=URL('cart','description')}}';
>>> url += '/' + id + '/';
>>> url += description;
>>> ajax(url,[],':eval');
>>>
>>> the reason I use url+= to pass parameters instead of using args in
>>> the URL helper is because the parameters are coming from the html 
>>> itself -
>>> they are not known in the controller py.
>>>
>>> now the problem is that it changes the description and I have no way
>>> to recover its original value. for example, when description is "askjdf 
>>> d
>>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string 
>>> in
>>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". 
>>> Obviously,
>>> it needs to do this conversion in order to pass  the parameter, but I 
>>> need
>>> to be able to recreate the original string, entered by the user.
>>>
>>> Is there a better way of doing this? I.e. a better way of passing a
>>> parameter in  a way that it could be "recreated" and stored in the 
>>> database
>>> exactly as typed by the user?
>>>
>> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/cyiquWAQU4w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> we

[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread villas
Hmm, not sure.  
Are you getting the values from  elements?
Try:  

var hereWeAre = $(this).val();


On Friday, 17 May 2019 12:13:03 UTC+1, Vlad wrote:
>
> I thought so and tried: 
>
> $(".EncodedDescriptionField").each( function(index, element ){
>  var hereWeAre = $(this).text();
>  var decodedString = atob(hereWeAre);
>  console.error(hereWeAre);
>  console.error(decodedString); 
> });
>
> this brings up an exception: 
>
> Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to 
> be decoded is not correctly encoded.
>
> I've also double-checked the values - they are correct. For example, when 
> I replace with the following: 
>
>  var decodedString = atob("Q29va2llcyBvbmU=");
>
> it decodes just fine, and the string itself I pick right from there - 
> that's the value it has when it throws exception. 
>
> Have no slightest clue what could possibly go wrong. 
>
>
> On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>>
>> Maybe you need to iterate through the class elements.  See this:
>>
>> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>>
>>
>>
>> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>>>
>>> Just to clarify: 
>>>
>>> the following works perfect  for one field by ID (decrypts it back):
>>> var encodedDescription = $("#CurrentCartDescription").text()
>>> $("#CurrentCartDescription").html(atob(encodedDescription));
>>>
>>> However, when I try to do it for a bunch of fields at once using class 
>>> (instead of id), it doesn't work - doesn't touch the values: 
>>>
>>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>>
>>> I am sure I am missing something basic... Greatly appreciate suggestions 
>>> - 
>>>
>>> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:

 I had no clue about it - I mean never heard the terms :)

 Thank you very much for point to the direction. After some googling, it 
 is almost working. 

 Encoding is just fine (using btoa). 

 When I read it back and want to decode - it's not yet behaving right. 
 I'm suspecting my javascript is a problem. 

 There is a bunch of fields which now have encrypted values (class 
 'EncodedDescriptionField'), and I am trying to use the following to 
 reclaim 
 the original values: 


 $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

 What am I doing wrong? (It doesn't change the values - they remain as 
 they are, encrypted)

 On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>
> Have you considered base64 encoding/decoding?
>
> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>
>> I have the following javascript in the view: 
>>
>> var id = $('#CurrentCartId').text();
>> var description = $(this).text();
>> var url='{{=URL('cart','description')}}';
>> url += '/' + id + '/';
>> url += description;
>> ajax(url,[],':eval');
>>
>> the reason I use url+= to pass parameters instead of using args in 
>> the URL helper is because the parameters are coming from the html itself 
>> - 
>> they are not known in the controller py. 
>>
>> now the problem is that it changes the description and I have no way 
>> to recover its original value. for example, when description is "askjdf 
>> d  
>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string 
>> in 
>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". 
>> Obviously, 
>> it needs to do this conversion in order to pass  the parameter, but I 
>> need 
>> to be able to recreate the original string, entered by the user. 
>>
>> Is there a better way of doing this? I.e. a better way of passing a 
>> parameter in  a way that it could be "recreated" and stored in the 
>> database 
>> exactly as typed by the user? 
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a20934f0-54a3-4bd9-95ff-0d3b60cbcfa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
I thought so and tried: 

$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 var decodedString = atob(hereWeAre);
 console.error(hereWeAre);
 console.error(decodedString); 
});

this brings up an exception: 

Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to 
be decoded is not correctly encoded.

I've also double-checked the values - they are correct. For example, when I 
replace with the following: 

 var decodedString = atob("Q29va2llcyBvbmU=");

it decodes just fine, and the string itself I pick right from there - 
that's the value it has when it throws exception. 

Have no slightest clue what could possibly go wrong. 


On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>
> Maybe you need to iterate through the class elements.  See this:
>
> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>
>
>
> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>>
>> Just to clarify: 
>>
>> the following works perfect  for one field by ID (decrypts it back):
>> var encodedDescription = $("#CurrentCartDescription").text()
>> $("#CurrentCartDescription").html(atob(encodedDescription));
>>
>> However, when I try to do it for a bunch of fields at once using class 
>> (instead of id), it doesn't work - doesn't touch the values: 
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> I am sure I am missing something basic... Greatly appreciate suggestions 
>> - 
>>
>> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>>
>>> I had no clue about it - I mean never heard the terms :)
>>>
>>> Thank you very much for point to the direction. After some googling, it 
>>> is almost working. 
>>>
>>> Encoding is just fine (using btoa). 
>>>
>>> When I read it back and want to decode - it's not yet behaving right. 
>>> I'm suspecting my javascript is a problem. 
>>>
>>> There is a bunch of fields which now have encrypted values (class 
>>> 'EncodedDescriptionField'), and I am trying to use the following to reclaim 
>>> the original values: 
>>>
>>>
>>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>>
>>> What am I doing wrong? (It doesn't change the values - they remain as 
>>> they are, encrypted)
>>>
>>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:

 Have you considered base64 encoding/decoding?

 quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>
> the reason I use url+= to pass parameters instead of using args in the 
> URL helper is because the parameters are coming from the html itself - 
> they 
> are not known in the controller py. 
>
> now the problem is that it changes the description and I have no way 
> to recover its original value. for example, when description is "askjdf d 
>  
>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string 
> in 
> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
> it needs to do this conversion in order to pass  the parameter, but I 
> need 
> to be able to recreate the original string, entered by the user. 
>
> Is there a better way of doing this? I.e. a better way of passing a 
> parameter in  a way that it could be "recreated" and stored in the 
> database 
> exactly as typed by the user? 
>


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/298b3f3d-a5fe-4fdf-80a0-b0455e094744%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread villas
Maybe you need to iterate through the class elements.  See this:
https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class



On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>
> Just to clarify: 
>
> the following works perfect  for one field by ID (decrypts it back):
> var encodedDescription = $("#CurrentCartDescription").text()
> $("#CurrentCartDescription").html(atob(encodedDescription));
>
> However, when I try to do it for a bunch of fields at once using class 
> (instead of id), it doesn't work - doesn't touch the values: 
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> I am sure I am missing something basic... Greatly appreciate suggestions - 
>
> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>
>> I had no clue about it - I mean never heard the terms :)
>>
>> Thank you very much for point to the direction. After some googling, it 
>> is almost working. 
>>
>> Encoding is just fine (using btoa). 
>>
>> When I read it back and want to decode - it's not yet behaving right. I'm 
>> suspecting my javascript is a problem. 
>>
>> There is a bunch of fields which now have encrypted values (class 
>> 'EncodedDescriptionField'), and I am trying to use the following to reclaim 
>> the original values: 
>>
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> What am I doing wrong? (It doesn't change the values - they remain as 
>> they are, encrypted)
>>
>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>>
>>> Have you considered base64 encoding/decoding?
>>>
>>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:

 I have the following javascript in the view: 

 var id = $('#CurrentCartId').text();
 var description = $(this).text();
 var url='{{=URL('cart','description')}}';
 url += '/' + id + '/';
 url += description;
 ajax(url,[],':eval');

 the reason I use url+= to pass parameters instead of using args in the 
 URL helper is because the parameters are coming from the html itself - 
 they 
 are not known in the controller py. 

 now the problem is that it changes the description and I have no way to 
 recover its original value. for example, when description is "askjdf d  
  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
 this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
 it needs to do this conversion in order to pass  the parameter, but I need 
 to be able to recreate the original string, entered by the user. 

 Is there a better way of doing this? I.e. a better way of passing a 
 parameter in  a way that it could be "recreated" and stored in the 
 database 
 exactly as typed by the user? 

>>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d0d5cc0b-1a55-45ad-a8c3-caeefa695d3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-16 Thread Vlad
Just to clarify: 

the following works perfect  for one field by ID (decrypts it back):
var encodedDescription = $("#CurrentCartDescription").text()
$("#CurrentCartDescription").html(atob(encodedDescription));

However, when I try to do it for a bunch of fields at once using class 
(instead of id), it doesn't work - doesn't touch the values: 
$(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

I am sure I am missing something basic... Greatly appreciate suggestions - 

On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>
> I had no clue about it - I mean never heard the terms :)
>
> Thank you very much for point to the direction. After some googling, it is 
> almost working. 
>
> Encoding is just fine (using btoa). 
>
> When I read it back and want to decode - it's not yet behaving right. I'm 
> suspecting my javascript is a problem. 
>
> There is a bunch of fields which now have encrypted values (class 
> 'EncodedDescriptionField'), and I am trying to use the following to reclaim 
> the original values: 
>
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> What am I doing wrong? (It doesn't change the values - they remain as they 
> are, encrypted)
>
> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>
>> Have you considered base64 encoding/decoding?
>>
>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>>
>>> I have the following javascript in the view: 
>>>
>>> var id = $('#CurrentCartId').text();
>>> var description = $(this).text();
>>> var url='{{=URL('cart','description')}}';
>>> url += '/' + id + '/';
>>> url += description;
>>> ajax(url,[],':eval');
>>>
>>> the reason I use url+= to pass parameters instead of using args in the 
>>> URL helper is because the parameters are coming from the html itself - they 
>>> are not known in the controller py. 
>>>
>>> now the problem is that it changes the description and I have no way to 
>>> recover its original value. for example, when description is "askjdf d  
>>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
>>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
>>> it needs to do this conversion in order to pass  the parameter, but I need 
>>> to be able to recreate the original string, entered by the user. 
>>>
>>> Is there a better way of doing this? I.e. a better way of passing a 
>>> parameter in  a way that it could be "recreated" and stored in the database 
>>> exactly as typed by the user? 
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e0c0e6cd-a2cd-498a-9e42-89e6de9a3a4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-16 Thread Vlad
I had no clue about it - I mean never heard the terms :)

Thank you very much for point to the direction. After some googling, it is 
almost working. 

Encoding is just fine (using btoa). 

When I read it back and want to decode - it's not yet behaving right. I'm 
suspecting my javascript is a problem. 

There is a bunch of fields which now have encrypted values (class 
'EncodedDescriptionField'), and I am trying to use the following to reclaim 
the original values: 

$(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

What am I doing wrong? (It doesn't change the values - they remain as they 
are, encrypted)

On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>
> Have you considered base64 encoding/decoding?
>
> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>
>> I have the following javascript in the view: 
>>
>> var id = $('#CurrentCartId').text();
>> var description = $(this).text();
>> var url='{{=URL('cart','description')}}';
>> url += '/' + id + '/';
>> url += description;
>> ajax(url,[],':eval');
>>
>> the reason I use url+= to pass parameters instead of using args in the 
>> URL helper is because the parameters are coming from the html itself - they 
>> are not known in the controller py. 
>>
>> now the problem is that it changes the description and I have no way to 
>> recover its original value. for example, when description is "askjdf d  
>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
>> it needs to do this conversion in order to pass  the parameter, but I need 
>> to be able to recreate the original string, entered by the user. 
>>
>> Is there a better way of doing this? I.e. a better way of passing a 
>> parameter in  a way that it could be "recreated" and stored in the database 
>> exactly as typed by the user? 
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1c716eaa-886a-4264-b80d-d51e035ecb55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-16 Thread João Matos
Have you considered base64 encoding/decoding?

quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>
> I have the following javascript in the view: 
>
> var id = $('#CurrentCartId').text();
> var description = $(this).text();
> var url='{{=URL('cart','description')}}';
> url += '/' + id + '/';
> url += description;
> ajax(url,[],':eval');
>
> the reason I use url+= to pass parameters instead of using args in the URL 
> helper is because the parameters are coming from the html itself - they are 
> not known in the controller py. 
>
> now the problem is that it changes the description and I have no way to 
> recover its original value. for example, when description is "askjdf d  
>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
> it needs to do this conversion in order to pass  the parameter, but I need 
> to be able to recreate the original string, entered by the user. 
>
> Is there a better way of doing this? I.e. a better way of passing a 
> parameter in  a way that it could be "recreated" and stored in the database 
> exactly as typed by the user? 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/71b98711-3c60-46c3-b421-5609a450bd7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.