Answer the question
In order to leave comments, you need to log in
How to send array or dictionary in XMLHttpRequest with JS in Python?
Good day!
Here is the code:
document.querySelector('#rateForm').onsubmit = () => {
const xhr = new XMLHttpRequest();
var rate = document.querySelector('#rate').value;
var text = document.querySelector('#text').value;
word = {"rate": rate, "text": text, "isbn": isbn}
const currency = word;
xhr.open('POST', '/comment', true);
xhr.onload = () => {
const data = JSON.parse(xhr.responseText);
console.log(data)
}
const data = new FormData();
data.append('currency', currency);
console.log(currency)
xhr.send(data);
return false;
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question