【问题标题】:No server response for jtable listActionjtable listAction 没有服务器响应
【发布时间】:2014-02-13 09:05:52
【问题描述】:

我正在使用 jtable 在 HTML 页面中显示表格记录。我的代码如下。在actions:,对于listAction,我可以为加载数据提供什么。我正在使用 nodejs 服务器。

在客户端:

$('#PersonTableContainer').jtable({  
          title: 'Table of people',  
        actions: {  
            listAction: '/api/users/all'  
        },  
        fields: {  
            user_id: {  
                key: true,  
                list: false  
            },   
            user_name: {  
                title: 'User Name',  
                width: '40%'  
            },  
            user_password: {  
                title: 'Password',  
                width: '20%'  
            }  
        }   
   });  
$('#PersonTableContainer').jtable('load');  

在服务器端:

app.get('/api/users/all',getAllUsers);

function getAllUsers(req, res)
{
    userdbConnection.query("SELECT user_id,user_name,user_password FROM user where user.user_name ='aaa' AND user_password='aaa'", function(err, rows, fields)
    {
        if (err)
            throw err;
        if (rows.length > 0)
        {
            var data = JSON.stringify({ Result : "OK", Records : rows[0]});
            res.send(data);
        }
        else
        {
            res.send('NO_DATA_FOUND');
        }
    });
};

如果我输入listAction: '/api/users/all'

没有响应表单服务器。请任何人都可以帮我解决。

【问题讨论】:

  • 这个网址正确吗? '/api/users/all

标签: jquery node.js jtable jquery-jtable


【解决方案1】:

在帖子中使用它而不是得到:

app.post('/api/users/all',getAllUsers);

【讨论】:

  • 您能否解释一下该代码,以便其他人可以从中学习,而不仅仅是复制和粘贴?另外,这不是 OP 已经在做的事情,或者它有什么不同吗?
  • 对不起,OP需要这样做:app.post('/api/users/all',getAllUsers);
猜你喜欢
  • 2014-06-04
  • 2011-08-22
  • 2017-01-09
  • 2017-01-04
  • 2018-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多