我正在编写node.js应用程序,我有点担心如何构建发送数据以发送到服务器.例如,当我想删除数据项时,我将所述项的id放在href属性中:
<a class='delete' href="1231">Delete this data</a> <!-- href is based on a variable I'm pulling from the server -->
//On click + ajax body.on('click','.delete',function(e){ e.preventDefault(); $.ajax({ type: 'POST',url: '/admin/report/detail/delete',data: {id: $(this).attr('href')},success: function(){ //Success message },error: function(){ //Error message } }); });