Nodejs ejs页面接收服务器返回信息的两种方式

第一种:
1,路由:
res.render("yjtz", {msg:msgstr1,data:datastr1});
2.ejs页面
<%=msg%> <%=data%>

第二种、在前端ejs页面使用ajax

$.ajax({
url:
OL_Action_Root+'/upload/imgxxvideo/'+id, //路由
type: 'POST',
data: formData,
async : false,//是否异步请求
cache: false,
contentType: false,
processData: false,
success: function(data){

if (data.err==0) {

document.getElementById("status").innerHTML = ""+data.msg+""
}

}
},
....

posted @ 2021-06-30 15:19  realhopezj  阅读(350)  评论(0)    收藏  举报