如果我使用输出行中带有注释和注释的输出变量,则在ajax成功的情况下我会收到警报提示,就像我在使用await的输出变量一样,我正在错误提示中显示警报,而不是提醒成功。
AJAX call:
$.ajax({
url:'/',
type: 'POST',
contentType: false,
processData: false,
cache: false,
data: data,
success: function(data){
alert(data));
},
error: function(){
alert('Error: In sending the request!');
}
})
Express:
app.post('/', fileUpload.upload,async (req,res)=>{
if(req.file !== undefined){
var output = await dbGet.getResult(`./storage/${req.file.filename}`);
console.log(output);
//output = [{'hi':'hello'}];
res.send(JSON.stringify(output));
}else{
res.send('unable to process request');
}
});