I'm trying to send the form data + additional parameter "id" to the server (Python, Google App Engine).
My form:
<form method="post" action="/" id="form1" runat="server" enctype='multipart/form-data'>
<div class="fileButtons">
<input type='file' id="imgInp" name="imgInp" accept="image/*"/>
<input type="submit" id="submit" name="action" value="Send"/>
<input type='button' id='remove' name="remove" value="Remove" />
</div>
</form>
Javascript function:
$( '#form1' ).submit(function( event ) {
event.preventDefault();
var data = $(this).serializeArray();
data.push({name: 'id', value: id});
$.ajax({
type: 'POST',
url: '/set_image',
data: data,
dataType: 'json',
success: function( resp ) {
console.log( resp );
}
});
});
data
only receives the id.
When debugging it with Firebug: I get the following:
this form#form1
imgInp input#imgInp property value = "2.jpg" attribute value = "null"
remove input#remove attribute value = "Remove"