So I stepped through the Web2py AJAX call in the debugger and found that 
the hang-up was due to jquery serialize method. That method wants a form 
variable name as input. The easiest solution is to wrap the table in a set 
of form tags and then modify the TD so that it contains a form input object 
like this:

<td> <INPUT type="text" id="s" name = "s" value="ajaxdata" onfocusout="ajax(
'{{=URL('data')}}',['s'],'target');"/> </td>

now the ajax call works as expected. A dash of CSS to hide the field 
borders and the end results look acceptable!  

Thank you for all  your help

On Friday, July 31, 2020 at 6:34:45 PM UTC-4, Rob Paire wrote:
>
> Hi All,
> I am trying to send data entered into the contenteditable feature of a row 
> object using a Web2py AJAX call, and it's not working. 
>
> The problem is illustrated below in a sample View file with two Ajax 
> calls. The first call, from the manual, uses an input form variable and it 
> works fine. In second call I tried passing the Name of the editable content 
> object to the AJAX call, but it does not work. In short, I want to send 
> document.getElementById('q').innerHTML as the data parameter of the ajax 
> function - how is this done?  I tried various combinations of dict strings 
> {'key':'value'} as the data parameter but nothing seemed to work.
>
> Note: the controller data function looks for both r and q request.vars 
>
> {{extend 'layout.html'}}
> <div id="target"></div>
> <p>Ajax call example from the manual works perfectly.. the data appears in 
> the target Above.</p>
> <form>
> <INPUT type="text" id="r" name = "r" value="web4py"/>
> <INPUT type="button" value="submit"
>        onclick="ajax('{{=URL('data')}}',['r'],'target');"/>
> </form>
> <hr>
>
> <table border="1" bgcolor="#FFFFFF" cellspacing="0" cellpadding="0" 
> align="center">
> <TR>
> <td COLSPAN="1" align="right" BGCOLOR="#EAACE1">  <b>
>
> This AJAX call does not work:</b> </td> <td 
> onfocusout="ajax('{{=URL('data')}}',['q'],'target');"  
>  contenteditable="true" id="q" name="q" COLSPAN="1" > ajaxdata </td>
>
> <td COLSPAN="1"> how do I pass the contenteditable data M to the AJAX 
> function? </td>
> </tr>
> </table>
>
> Thank you kindly
> -Rob
>
>
>

-- 
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/6b8bc494-d26d-4136-bb02-2cbc4b498f14o%40googlegroups.com.

Reply via email to