i want to send form details to node.js server by using ajax function i am able see in console whatever i am sending
But i am not able to get any response from node.js server to html ajax function
server.js
var http = require('http');
http.createServer(function(request, response) {
request.on('data', function (chunk) {
var res=chunk.toString('utf8');
var obj=JSON.parse(res);
var region=obj.region;
var os=obj.os;
console.log(region);
console.log(os);
});
//var data="hi";
//how to send data
//response.send(data);
}).listen(8088);
client.html
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
function myFunction() {
var region = document.getElementById("region").value;
var os = document.getElementById("os").value;
var data = {};
data.region = region;
data.os = os;
$.ajax({
type: 'POST',
jsonpCallback: "callback",
datatype: 'jsonp',
data: JSON.stringify(data),
//contentType: 'application/json',
url: 'http://127.0.0.1:8088/', //node.js server is running
success: function(data) {
alert("success");
console.log(JSON.stringify(data));
},
error: function (xhr, status, error){
console.log('Failure');
alert("failure");
},
});
}
</script>
</head>
<body>
<form>
<input type="text" id="region" name="region"/>
<input type="text" id="os" name="os"/>
<input type="button" value="search" class="fil_search" onclick="myFunction()"/>
</form>
</body>
</html>
help me out from this how get response from node.js server. just i want see the alert box of success message in html page