javascript - Serialize form and combine with other value in ajax data -
this question has answer here:
- jquery form.serialize , other parameters 5 answers
i have ajax this.
var idlapkondisi = $('#id_laporan_pemeriksa').val(); var data = $('#myformkondisi').serialize(); $.ajax({ type:'ajax', method:'post', url:url, datatype:'json', success:function(response){ }, error:function(response){ console.log(response); } }) })
how can make 2 value in ajax data while value serialize data form ? format ?
data:{data,idlapkondisi:idlapkondisi},
use serializearray instead of serialize.
var idlapkondisi = $('#id_laporan_pemeriksa').val(); var data = $('#myformkondisi').serializearray(); data.push({name: "idlapkondisi", value: idlapkondisi}); $.ajax({ type:'ajax', method:'post', url:url, datatype:'json', success:function(response){ }, error:function(response){ console.log(response); } }) })
Comments
Post a Comment