-1

This is what i got so far

var express = require('express');
var app = express();

app.get('/data', function(req, res){
    res.send('hello world'); //replace with your data here
});

app.listen(8888);

the html

<div id="test"></div>
<input type="button" id="but" value="Link">


<script>
    $(document).ready(function() {
        $('#but').click(function(){
            $.get('http://localhost:8888/data', {}, function(data){
                $("#test").append(data);
            });
        });
    });
</script>

I just want to display the hello world inside the div can somebody please help?

Salyeri
  • 1
  • 3

2 Answers2

1

You can also change the div to have the class named test.

Also, in some systems, using the port 8888 doesn't work. Try 8080 instead.

Hezi Shahmoon
  • 388
  • 1
  • 7
0

.test is a class selector. It matches 0 elements because none of your elements are a member of that class.

You have <div id="test">. An id is not a class.

An ID selector uses #, not .

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Possibly also a [duplicate of this](http://stackoverflow.com/questions/35553500/xmlhttprequest-cannot-load-https-www-website-com/35553666#35553666) but you didn't mention any errors on the Console in your browser's developer tools. – Quentin Mar 09 '17 at 10:43