I'm new on Node, I have the following problem, I have a http://mydomain.com/mypage.php that do some stuff, and I want to call http://mydomain.com:8080 (where is located the node server).
var server = require('http').createServer(function(req, res){
res.writeHead(200, {'Content-Type': 'text/javascript'});
res.end('$("#messages").append("<br> test123");');
});
server.listen(8080);
Seems to work, because I receive in my client :
$("#messages").append("<br> test123");
but the code receive, is not execute!
any idea ?
thanks in advance Dany
php Code simplified (mypage.php):
<!DOCTYPE html>
<html lang="en">
<head>
<title>demo game </title>
<script src="/js/jquery-1.8.3.min.js"></script>
<script src="http://127.0.0.1:8080"></script>
</head>
<body>
<div id="messages"></div>
<input type="text" id="text-input">
<input type="button" value="Send" id="send-button">
</body>
</html>
try returning this
$(function(){
$("#messages").append("<br> test123");
})
this might be happening because script is being executed before div#messages is loaded and hence there is no reference to div#messages