Answer the question
In order to leave comments, you need to log in
How to get message value sent via res.end(message) in ajax?
How to get the value for further processing and correct display in ajax
if the data was sent from node.js with res.end(...)?
In particular, this point is of interest:
var xhr = new XMLHttpRequest();
xhr.open("GET", "/subscribe", true);
xhr.onload = function() {
var li = document.createElement('li');
li.textContent = this.responseText;
message.appendChild(li);
subscribe();
};
xhr.onerror = xhr.onabort = function() {
setTimeout(subscribe,300);
};
xhr.send('');
Answer the question
In order to leave comments, you need to log in
app.get('/getapi', function(req, res, next){
let body = req.body;
return res.json({data: body});
});
$.get("/getapi",
{
param1: "param1",
param2: "param2"
},
onAjaxSuccess
);
function onAjaxSuccess(data){
console.log(data);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question