T
T
Timofey Mikhailov2018-02-20 15:58:12
JavaScript
Timofey Mikhailov, 2018-02-20 15:58:12

Please show an example of a POST request?

Hello, can you show an example of sending a POST request.
In fact, I need to transfer a large piece of text to PHP functions, and that's it.
Important: the example is needed WITHOUT jQuery.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2018-02-20
@JimmiJanger

It is assumed that your text is in the form field

var formElement = document.querySelector("form");
var request = new XMLHttpRequest();
request.open("POST", "submitform.php");
request.send(new FormData(formElement));

or add it yourself
var big_text = "И таак сойдееет!";
var formElement = document.querySelector("form");
var formData = new FormData(formElement);
var request = new XMLHttpRequest();
request.open("POST", "submitform.php");
formData.append("big_text", big_text);
request.send(formData);

N
Nurlan, 2018-02-20
@daager

youmightnotneedjquery.com/#post

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question