美文网首页
express教学(3)jQuery的get和post接参

express教学(3)jQuery的get和post接参

作者: Yossef | 来源:发表于2017-12-20 19:39 被阅读0次

get前台编写形式:

$.get('/admin/pass?id='+id,function(rehtml){

});

使用上述方法会调用/admin/pass路径 并将id传到后台

get后台接受编写形式:

letid = req.query.id

get接参使用req.query来接收前台get方法

post前台编写形式:

$.post('/admin/pass,{id:id},function(rehtml){

});

注意jQuery post传参的方法在前台与get不同点就在于 传参数的地方 post是直接把参数放进对象里

post后台接受编写形式:

post后台接到参数的方法时 req.body   req.body.id

相关文章

网友评论

      本文标题:express教学(3)jQuery的get和post接参

      本文链接:https://www.haomeiwen.com/subject/cqrnwxtx.html