1

私は Node.JS と Express を初めて使用するので、これが初心者の質問である場合はご容赦ください。入力するメソッドとして「get」を使用するように構成された JQuery EasyUI DataGrid を使用しています。ただし、リクエストが Express サーバーに到着すると、入ってくる POST のように見え、間違ったサーバー メソッドが呼び出されています。

これで数日間立ち往生しています...助けてください...

app.js から抽出

 app.configure(function(){
   app.set('port', process.env.PORT || 3000);
   app.set('views', __dirname + '/views');
   app.set('view engine', 'jade');
   app.use(express.favicon());
   app.use(express.logger('dev'));
   app.use(express.bodyParser());
   app.use(express.methodOverride());
   app.use(express.cookieParser('your secret here'));
   app.use(express.session());
   app.use(app.router);
   app.use(express.static(path.join(__dirname, 'public')));
 });

 app.configure('development', function(){
   app.use(express.errorHandler());
 });

 app.get('/', routes.index);
 app.get('/users', user.list);
 app.get('/TrainingPlans', TrainingPlans.findAll);    // THIS IS THE ONE I WANT TO USE 
 app.get('/LoadSampleData',populateDB);
 app.get('/ClearAllTrainingPlans',clearTPsFromDB);
 app.get('/TrainingPlans/:id', TrainingPlans.findById);
 app.put('/TrainingPlans/:id', TrainingPlans.updateTrainingPlan);
 app.delete('/TrainingPlans/:id', TrainingPlans.deleteTrainingPlan);

INDEX.HTML から抽出

 <table id="tpstable" title="Training Plans" class="easyui-datagrid"      style="width:550px;height:250px"
        url="/TrainingPlans"
        toolbar="#toolbar"
        method="get"
        rownumbers="true" fitColumns="true" singleSelect="true">
     <thead>
     <tr>
         <th field="name" width="50">Name</th>

         <th field="_id" width="70">_id</th>

         <th field="description" width="100">Description</th>
     </tr>
     </thead>
 </table>
 <div id="toolbar">
     <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"      onclick="create_trainingplan()">Create Plan</a>
     <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true"      onclick="edit_trainingplan()">Edit Plan</a>
     <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true"      onclick="delete_trainingplan()">Remove Plan</a>
 </div>

HTMLテーブル定義の代わりにJSを使用してData DataGridを設定することで、最後まで動作するようになりました。

$('#tpstable').datagrid({
    url:'/TrainingPlans',
    toolbar:"#toolbar",
    method:"get",
    rownumbers:"true",
    fitColumns:"true",
    singleSelect:"true" 
 });

ご協力ありがとうございました...そして

コーマック

4

0 に答える 0