Created
May 4, 2016 10:42
-
-
Save anonymous/313b68b31de00cb4dc0816eede678131 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
前端的代码: | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
$("#submitInfo").click(function () { | |
var form = $("#login_form"); | |
var data = { | |
username: form.find("#inputUsername").val(), | |
password: hex_md5(form.find("#inputPassword").val()) | |
} | |
$.ajax({ | |
type: 'post', | |
url:'/signin', | |
data: data, | |
success: function(data) { | |
console.log('success'); | |
console.log(JSON.stringify(data)); | |
} | |
}) | |
}); | |
}); | |
</script> | |
后端express的代码: | |
''' | |
router.post('/', function (req, res, next) { | |
console.log(req.body); | |
controller.user.username = req.body.username; | |
controller.user.password = req.body.password; | |
controller.user.isRemember = req.body.isRemember; | |
controller.api = new client(controller.user.username, | |
controller.user.password); | |
//res.json(req.body); | |
controller.api.getAccessToken(function (token, err) { | |
if (!err) { | |
res.json({success:1}); | |
console.log(token); | |
} else { | |
res.json({error:err}); | |
console.log(err); | |
} | |
}); | |
}); | |
getAccessToken需要访问其他的url。 |
router.post('/', function (req, res, next)
路由配错了?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
代码没问题,把你报错的详细信息发上来。