Took a surprisingly amount of time(which is why i was asking for help), but 
ended up with a solution in the end.

controller:

def jsontest1():
   import gluon.contrib.simplejson
   session.cart = gluon.contrib.simplejson.loads(request.post_vars.cart)
   return session.cart

def jsontest():
   return dict()
 
def jsontest2():
   return dict(cart=gluon.contrib.simplejson.dumps(session.cart))

view

{{extend 'layout.html'}}

{{=cart}}
   
   <button type="button" onclick="ajaxtest()">Try it</button>

javascript:

function ajaxtest(){
    $.ajax({
        type: "POST",
        url: "/partyworldminh/cart/jsontest1.json",
        data: "cart="+JSON.stringify(items)
    }).done(function( msg ) { alert(msg);});
}

On Monday, October 22, 2012 4:52:30 PM UTC+10:30, RyanTheLeach wrote:
>
> Anyone have a super simple example of how to go from a javascript object, 
> being sent to web2py via jquery.ajax and being returned and processed?
>
> Everything that I've come across has either not worked, or has been 
> sending simple key value pairs.
>
> All I want to be able to do is send a shopping cart full of products and 
> quantities in to web2py to be stored in the session.

-- 



Reply via email to