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

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

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:

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

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

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

[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: -

[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

[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

[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 +

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();

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

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

[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 =

[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); });

[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

[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

[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

[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