I have several areas where I use AJAX to submit text fields.
var name = $("input#name").val();
$.ajax({
type: "POST",
url: "bin/process.php",
data: "&name=" + name,
success: function() {
//handle response here
}
});
However, I can’t figure out how to do this if the input type is a file? Doing
var name = $("input#file").val(); doesn’t seem to work..
By default, jQuery cannot POST a form via AJAX if it contains a upload field.
You can try this plugin: http://jquery.malsup.com/form/