I am new to nodejs and jquery, I just want to get some data from a server and use that data to update a page:
Client side (uses jquery): as you can see, I want the text inside '#info' change to data got from server.
$('#button').click(function(){
$.post("/search", function(data) {
$('#info').text(data);
});
});
Server side (uses express):
app.post('/search', function(req, res){
res.send('hello');
})
The problem is: instead of updating the content of '#info', the content of the whole webpage will be gone and only 'hello' is printed on the webpage.
The client side seems unable to get the data from the server side, but I cannot figure it out why.