当JQuery函数-AJAX-未被调用时上传正在工作,当我调用JQuery然后发送数据工作但上传不是
function addAdv(event) {
.....
$.ajax({
type: 'POST',
data: newUser,
url: '/addadv',
dataType: 'JSON'
}).done(function( response )...}
AJAX:
router.post('/upload', upload, function (req, res, next) {
console.log(req.file);
res.status(204).end();
});
router.post('/addadv', function(req, res) {
Feed.collection.insert(req.body, function(err, result){
res.send(
(err === null) ? { msg: '' } : { msg: err }
);
});
});
Node.JS路由:
Automotive Service Worker
Community Police Services Aide
DEPUTY SHERIFF
COUNSELOR, JUVENILE HALL
Swimming Instructor
FIREFIGHTER
Porter
Account Clerk
Deputy Sheriff
Assistant Retirement Analyst
POLICE OFFICER III
Patient Care Assistant
Public Service Trainee
PUBLIC RELATIONS OFFICER
SPECIAL NURSE
除非我尝试在AJAX表单中合并上传输入,否则每个函数都可以正常工作。