javascript - Ajax send data to Node.js client then send to Node.js server -


is possible jquery.ajax send data node.js client,then after receive data send node.js server ?. possible ?

myajax

$.ajax({    type:'post'    data:{data:hello},    url: '' //here don't know how point node.js client    success:function(data){      }   }); 

servarapp.js

 var net = require('net');  var clients = [];  var server = net.createserver(function (socket) {     clients.push(socket);   });    server.listen(1337,'localhost',function(){    console.log("server listening in port 1337"); }); 

client.js

var net = require('net');  var client = new net.socket(); client.connect(1337, '127.0.0.1', function() {     console.log('connected');     client.write('hello, server!); });  client.on('data', function(data) {     console.log('received: ' + data);     client.destroy();  });  client.on('close', function() {     console.log('connection closed'); }); 

thank in advance.

an ajax request browser can sent http server. in client.js seem have created socket on port 1337 cannot work because ajax through http protocol. work can use http framework such express create http server.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -