paint-brush
Conditional API Responses for JavaScript vs. HTML Forms: An Essential Guideby@austingil
238 reads

Conditional API Responses for JavaScript vs. HTML Forms: An Essential Guide

by Austin Gil6mJanuary 20th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Today, I’ll show you how to detect whether an HTTP request was submitted via an HTML form or with JavaScript. When a form is submitted the browser sends the request as a page navigation, causing the next page to render whatever the server responds with. If the response is JSON, it will render that JSON string to the page. We can use this header to distinguish between one or the other.
featured image - Conditional API Responses for JavaScript vs. HTML Forms: An Essential Guide
Austin Gil HackerNoon profile picture
Austin Gil

Austin Gil

@austingil

I want to help you build better websites. It's fun!

L O A D I N G
. . . comments & more!

About Author

Austin Gil HackerNoon profile picture
Austin Gil@austingil
I want to help you build better websites. It's fun!

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here