Tuesday, 15 March 2011

javascript - Post multiple jquery with ajax to python -



javascript - Post multiple jquery with ajax to python -

my question: i'm trying post multiple info using ajax request. don't python script. error console, says:

data: { serializeddata1, serializeddata } error: uncaught syntaxerror: unexpected token ,

but if remove , more , more errors syntax errors. if edit javascript this: data: serializeddata1 wil work isn't want.

var valueid = $(this).parent().parent().find(".inputliveid")// id want var serializeddata1 = valueid.serialize() var $form = $(this); // want value var serializeddata = $form.serialize(); request = $.ajax({ url: "/accounts/editnad/", type: "post", data: { serializeddata1, serializeddata } }); request.done(function (response, textstatus, jqxhr){ console.log(response) }); request.fail(function (jqxhr, textstatus, errorthrown){ console.error( "the next error occured: "+ textstatus, errorthrown ); });

python script:

def editnad(updatenad): result = false updid = updatenad.post.get("newid") newnr = updatenad.post.get("nadcodenr") newbesch = updatenad.post.get("nadbeschikbaar") homecoming httpresponse(updid,newnr)

you need pass name/value pairs in ajax call, example

$.ajax({ url: 'myscript.py', data: {form1: serializeddata1, form2: serializeddata}, success: function(response) { //do response } });

then in python

updid = udatenad.post.get('form1').updid

you'll note didn't assign ajax phone call variable, used success callback instead. if want utilize promise can assign it, , utilize resolution/broken callbacks. guess i'm old school.

javascript jquery python ajax

No comments:

Post a Comment