I am new to Node.JS and Express so forgive me if this is a newbie question. I am using a JQuery EasyUI DataGrid which is configured to use "get" as the method to populate. However when the request arrives on the Express server it SEEMS to be a POST that comes in and the wrong server method is being called.
Stuck on this for a couple of days now... please help...
EXTRACT FROM 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);
EXTRACT FROM 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>
GOT IT WORKING INT THE END by setting the Data DataGrid from JS using instead of in the HTML table definition.
$('#tpstable').datagrid({
url:'/TrainingPlans',
toolbar:"#toolbar",
method:"get",
rownumbers:"true",
fitColumns:"true",
singleSelect:"true"
});
Thank you all for your help... and
Cormac