Send FormData and String Data Together Through JQuery AJAX -


i have below uploads image using jquery's ajax function

var id = <?php echo $id; ?>; var img_data = new formdata($("form")[0]);  $.ajax({     url: 'add.php',     data: img_data,     contenttype: false,     processdata: false,     type: 'post',     success: function(data){         alert(data);     } }); 

i'd include string formdata sent. tried following, no luck

data: img_data {id: id}, 

what's correct syntax here?

use append

var img_data = new formdata($("form")[0]); img_data.append('id', id);  

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -