javascript - jQuery not serialize correctly -
i want ajax submit 2 form (for user
, client
). 2 forms identical user
serialized expected, other 1 isn't. 2 forms return
js function onsubmit="return edituser();"
, onsubmit="return editclient();"
respectively. try alert out serialize data , show user:
id=7&username=somethingelse&password=123&is_admin=0&client=1
and client:
id=2&name=&logo=&phone=&email=&active=1&street=&city=&state=43&zip_code=
with fields filled (the 3 values prefilled php code).
here js code ajax:
function edituser() { console.log($('#edituserform').serialize()); $.ajax({ type: 'post', url: 'edituser.php', data: $('#edituserform').serialize(), cache: false, datatype:'json', contenttype: "application/x-www-form-urlencoded; charset=utf-8", }).always(function(){ renderusers(); $('body').removeclass('modal-open'); $('.modal-backdrop').remove(); }); return false; } function editclient() { console.log($('#editclientform').serialize()); $.ajax({ type: 'post', url: 'editclient.php', data: $('#editclientform').serialize(), cache: false, datatype:'json', contenttype: "application/x-www-form-urlencoded; charset=utf-8" }).always(function(){ renderusers(); $('body').removeclass('modal-open'); $('.modal-backdrop').remove(); });; return false; }
comment question, know i'm bad explaining stuffs. helping.
so sum question: why user , client function identical (different in id , fields in form) user works , client doesn't?
for more info please use this see result. login info : admin pass. after logged in, click on users tab in left sidebar , try update client, see not working still can edit user
Comments
Post a Comment