這是我走到這一步,如何從一個節點顯示數據的js割斷我的html頁面
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);
的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>
我只是想在div裏面顯示hello世界有人可以幫忙嗎?
你導入jQuery嗎? – pandamakes
是的,它在html的頭部 – Salyeri