var formdata = new FormData(); formdata.append('userid', 'jeff'); formdata.append('password', 'amazon'); $.ajax({ type: 'post', url: url, dataType: 'text', // The reply is text data: formdata, // Options to tell jQuery not to process data or worry about content-type cache: false, contentType: false, processData: false, success: function(reply) { // ... }, error: function(jqXHR, textStatus, errorThrown) { // ... }, });
Programming Tips - jQuery: post FormData with $.ajax()
Date: 2022jul20
Language: javaScript
Q. jQuery: post FormData with $.ajax()
A. By default $.ajax() with type: 'post' doesn't send your
formdata as multipart-form-data. To make that happen add
cache: false, contentType: false, processData: false.
Like this: