js array post to controller gives None value

38 views
Skip to first unread message

Maurice Waka

unread,
May 30, 2020, 3:21:04 AM5/30/20
to web2py-users
I'm getting a 'None' value when posting an array to controller (array posted db). What could I be doing wrong?
Here is my code

<select name="result" id="result" question="Click on the button below to know your answer.">
   
<option value="my result" onclick='myFunction();'>Yes</option>
   
<option value="no result">No</option>
</select>
<script type="text/javascript">
       
function myFunction();{
           
var result = ["bat", "cat", "dog", "sun", "hut", "run"];
            ajax
('{{=URL('chat', 'synchptoms')}}' + '?result=' + result, [], ':eval');
       
}
</script>

controller

@auth.requires_login()
def synchptoms():      
        value
= request.vars.result#json(request.body.read())
        array
= [1, 2, 3, 4, 5]
        db
.answers.insert(message=value)
       
return dict(array=json(array),value=value)

Maurice Waka

unread,
May 31, 2020, 4:18:08 AM5/31/20
to web2py-users
After removing  the .. onclick='myFunction()';

it now works well
Reply all
Reply to author
Forward
0 new messages