I am having trouble using the express/node. I created a route called "/searching" which is working fine because I already tested it. I also have an html file which is not part of the express project; It is not located in the 'public' or in the 'views' folders. I am trying the access the '/searching' route from this file. I saw in the cmd that the request is being done, but I can't retrieve the data from the ajax I am doing.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<p id="container">Hello</p>
<script>
$(document).ready(function(){
$("#container").click(function(){
$.get('http://localhost:3000/searching',function(data){
$("#container").html(data);
}); }); });
</script>
</body>
</html>
The node/express part that corresponds to the route is:
app.get('/searching', function(req, res){
res.send("result");
});
I expect to see the "Hello" text changed to "result" when I click this, but it is not working. Any suggestion?