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}}
>> <br />
>> {{=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 <abasta...@gmail.com> 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
>>>  
>>> <https://groups.google.com/d/msgid/web2py/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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.

Reply via email to