Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- method: "POST",
- contentType: 'application/json',
- dataType: 'json',
- url: "localhost:8000/test",
- data: JSON.stringify({user:"john", pass:"123"}),
- error: function () {
- alert('error');
- },
- success: function (data) {
- alert('success');
- }
- });
- var express = require('express');
- var app = express();
- var bodyParser = require('body-parser');
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({ extended: true }));
- app.post('/login', function (req, res) {
- var user = req.body.user;
- var password = req.body.pass;
- if(user == 'john' && password == '123') {
- res.status(200);
- } else {
- res.status(401);
- }
- });
- app.listen(8000, function () {
- console.log('Example app listening on port 8000!');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement