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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay