Search code snippets, questions, articles...

JQuery Ajax post request with form data

The below code can be useful to send ajax post request with form data using jQuery.
var form_data = new FormData();    
form_data.append( 'username', 'John Deo');
form_data.append('email', '[email protected]');

$.ajax({
    url: 'api_url/endpoint',
    data: fd,
    processData: false,
    contentType: false,
    type: 'POST',
    success: function(response){
        console.log(response);
    }
});
Was this helpful?
0 Comments