# Simplifying Dynamic Web Development with Django and HTMX (Part 4): How to Handle Payloads? When sending POST requests using `fetch` for Ajax in traditional JavaScript, you typically assemble the payload directly using `JSON.stringify()`. It generally looks like this: ```JavaScript fetch("/api/todos/", { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": csrftoken }, body: JSON.stringify({ title: "장보기", done: false, priority: 3 }) }) ``` But what about **HTMX**? How exactly does `hx-post` send data to the server? Many examples only demonstrate very simple functionalities, making it surprisingly difficult to find practical examples for constructing and sending complex payloads. In this post, we'll thoroughly explore HTMX's data transmission methods and how to handle them on the server-side.  ------ ## HTMX Data Transmission Methods {#sec-1f930b1a0dad} The approach to payloads with `fetch` and data transmission with `hx-post` are quite distinct. With `fetch`, developers directly create objects and convert them to JSON for the request body. In contrast, **HTMX primarily collects values from the DOM for transmission**. HTMX's philosophy isn't about "directly assembling JS objects," but rather **"gathering values from HTML elements to construct request parameters."** It typically uses the following three methods for this purpose. ### 1) Sending Values Based on Forms {#sec-f5086851ac19} This is the most HTML-native approach and integrates well with Django. ```html
``` In this scenario, HTMX collects the input values within the form and sends them with the request. The default encoding is **URL-encoded form data**, just like a standard form submission. In a Django view, you can receive them as usual: ```Python def create_todo(request): title = request.POST.get("title") priority = request.POST.get("priority") done = request.POST.get("done") ``` ### 2) Including Values from Other Elements Without a Form: `hx-include` {#sec-a2c0e1f9e1ca} This is used when you want to attach `hx-post` to a single button and selectively send input values located elsewhere. ```HTML ``` `hx-include` includes the values of the specified elements in the request. This allows you to achieve a payload-like result without wrapping everything in a `