DEV Community

Cover image for Get form data and POST with JavaScript(jQuery)
Alim AJ
Alim AJ

Posted on

Get form data and POST with JavaScript(jQuery)

Intro

This article is a note of what I found and applied to fetch data on a form and send it in jquery with the POST method.

Try

get form data

var fd = new FormData(document.getElementById('filter-data'))
// if you want to add data use append
fd.append('limit',limit);
fd.append('start',start);
Enter fullscreen mode Exit fullscreen mode

POST data with jquery

$.ajax({
    url: "your_url",
    method: "POST",
    data: fd,
    cache: false,
    contentType: false,
    processData: false,
    success: function(data){
        // action success
    }
})
Enter fullscreen mode Exit fullscreen mode

like if you find this useful

Top comments (0)