Created
March 1, 2016 05:33
-
-
Save rnjailamba/dbdfdc54996a48294ff4 to your computer and use it in GitHub Desktop.
Node JS - Send AJAX POST data and read from Node/Express js router
This file contains hidden or 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
// SEND OTP | |
// ============================================== | |
router.post('/sendOTP',function(req, res){ | |
console.log('body: ' + JSON.stringify(req.body)); | |
} |
This file contains hidden or 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 data = {}; | |
data.title = "title"; | |
data.message = "message"; | |
$.ajax({ | |
url:"/users1/sendOTP", | |
type: 'POST', | |
async: true, | |
data: JSON.stringify(data), | |
contentType: 'application/json', | |
context: this, | |
cache: false, | |
processData: false, | |
success: function(response) { | |
}, | |
error: function(response) { | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment