Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

php - Page content not loading/displayed after send request in res.render() using Node

I am having server file i.e.node_app.js , client files login.php,group.php and display_group_details.php.

After login using Jade (view template engine) login page redirected to group.php, here on group page, I have table with group list having columns id,group_name,description,capacity and last column with 'show detail' button.

When I click on 'show detail' button I want to open popup with details of selected group. As per my code popup get opened, URL is showing in address bar but no page content displayed initially, it displayed when I refresh the page.

It must open popup with page content not after refresh.

Here is my code:

app.get('/joined_group', function (req, res) {
selected_group_id = req.query.grpid;

var qry= "SELECT * FROM `groups`  where `group_id` = "+selected_group_id;
    con.query(qry, function(err, result, fields)
    {
            res.render('group_details');//name of jade file
    });
});

In Jade file named group_details i have code like :

include details.php

What I am doing wrong or what things are missing?

NOTE: Previously when I am not using xampp to run this application code was for button click like :

<button class="btn btn-primary"  onclick="window.open('/joined_group?grpid=1','name','width=1200,height=600','_blank')">
                                        Join</button>

Now I am using xampp so as ports are different for Xampp (Apache) and Node http server, code is like

<button class="btn btn-primary"  onclick="window.open('localhost:8087/joined_group?grpid=<?php echo $group['group_id'];?>','name','width=1200,height=600','_blank')">
                                        Join</button>

Using this popup get opened but blank, it displays content after refresh, but it should not be like that.

NOTE: please have a look on code I have edited, node_app.js after button click (as shown earlier above but with some changes , send parameters along with file as )

  res.render('group_details',{grp_id:selected_group_id,grp_name:result[0].grp_name,loggeduser:'test'});

and group_details.jade :

   script(type='text/javascript')
  | var grpid="#{grpid}"
  | var grp_name="#{grp_name}"
  | var loggeduser="#{loggeduser}"
  include details.php

am I doing something wrong or missing some in jade file or node node_app.js file while loading page after button click?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Hi Finally i got what to be done if using xampp as well as node.js server.

I have followed answer of "T.Todua" of post : How to install nodejs on Xampp localhost

its working now. Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...