DEV Community

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

Posted on

2 2

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay