本文介绍了Nodejs + ExpressJS + Jade +发布无渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1˚-客户:
$.ajax({
type: 'POST',
data: data,
url: '/someposturl',
success: function (data) {
console.log('success');
// $('body').html(data); // i don't want it, but if not so, nothing happens (render)
}
});
2˚-服务器:
app.get('/criptografar', function (req, res) {
console.log(req.something);
res.render('somepage', {
somevar: withsomevalue
});
//-I want this to work like a normal post
});
3˚-客户端->'somepage'-如果没有在客户端中显示,则不会呈现:
3˚ - Client -> 'somepage' - not rendered without this in the client:
$('body').html(data); // i don't want it, but if not so, nothing happens (render)
或这个
$('html').html(data); // i don't want it, but if not so, nothing happens (render) <- Jade Layout error.
推荐答案
因为您是从客户端的$.ajax
调用它的.如果从服务器端调用它,效果很好
Because you call it from $.ajax
from client side.It works good if you call it from server side
要使页面从服务器端调用URL,应将其添加到表单中
To make a page call a URL from server side, you should add this to your form
form(role="form" method="POST")
请参阅此问题. Express.js不会在后期操作中呈现
这篇关于Nodejs + ExpressJS + Jade +发布无渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!