This is similar to Stream data with Node.js, but I don't feel that question was answered sufficiently.
I'm trying to use a jQuery ajax call (get, load, getJSON) to transfer data between a page and a node.js server. I can hit the address from my browser and see 'Hello World!, but when I try this from my page, it fails and shows that I get no response back. I setup a simple test page and hello world example to test this:
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8 />
<title>get test</title>
</head>
<body>
<h1>Get Test</h1>
<div id=test></div>
<script src=//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js></script>
<script>
$(document).ready(function() {
//alert($('h1').length);
$('#test').load('http://192.168.1.103:8124/');
//$.get('http://192.168.1.103:8124/', function(data) {
// alert(data);
//});
});
</script>
</body>
</html>
and
var http = require('http');
http.createServer(function (req, res) {
console.log('request received');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn');
}).listen(8124);