所以我有下面的代码:检索Post Request响应并存储到变量中?
var formData = new FormData();
formData.append("title", document.getElementById("title").value);
formData.append("html",my_html);
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://www.mywebsite.com/index");
xhr.send(formData);
xhr.onreadystatechange = function()
{
// If the request completed, close the extension popup
if (req.readyState == 4)
if (req.status == 200) window.close();
};
服务器应该发回一个JSON格式的响应。 如何检索并将其存储在变量中? 任何人都可以帮忙吗?