Created
May 20, 2014 20:03
-
-
Save saumya/402d2f035b23d7d08877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
var express = require('express'); | |
var app = express(); | |
app.all('*', function(req, res, next) { | |
res.header("Access-Control-Allow-Origin", "*"); | |
res.header("Access-Control-Allow-Headers", "X-Requested-With"); | |
next(); | |
}); | |
app.get('/', function(req, res){ | |
res.send('Hello World'); | |
}); | |
app.get('/myTestAPI', function(req, res){ | |
var a = (req.query.argOne);//getting param from the request | |
var b = (req.query.argTwo); | |
var resultOBJ = {'responseText':'this is success','someMoreData':'Extra data'}; | |
res.send(resultOBJ); | |
}); | |
var server = app.listen(3001, function() { | |
console.log('Listening on port %d', server.address().port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//call from frontend
$.ajax({
url: reqURI,
type: "GET",
cache: false,
data: { 'argOne':'First Data', 'argTwo':'more Data'},
dataType: "json",
success: function(result) {
console.log(result);
},
error: function(error) {
console.log('AJAX : ERROR : Problem With server ');
console.log(error);
}
});