var async = require('async');
function callbackhandler(err, results) {
console.log('It came back with this ' + results);
}
function takes5Seconds(callback) {
console.log('Starting 5 second task');
setTimeout( function() {
console.log('Just finshed 5 seconds');
callback(null, 'five');
}, 5000);
}
function takes2Seconds(callback) {
console.log('Starting 2 second task');
setTimeout( function() {
console.log('Just finshed 2 seconds');
callback(null, 'two');
}, 2000);
}
async.series([takes2Seconds(callbackhandler),
takes5Seconds(callbackhandler)], function(err, results){
console.log('Result of the whole run is ' + results);
})
Run Code Online (Sandbox Code Playgroud)
输出如下所示:
Starting 2 second task
Starting 5 second task
Just finshed …Run Code Online (Sandbox Code Playgroud) 将JSON与传统表单编码一起发布为从HTML表单向服务器提交数据的数据格式.HTML表单是动态的,用户可以添加新行(例如)并填写数据.有一个论点是在这种情况下使用带有MVC框架的表单字段更容易,因为像Spring MVC这样的MVC框架负责对表单的绑定(在动态生成的HTML中生成id等),我们可以在控制器在使用AJAX作为表单编码内容类型发布表单时收集这些值.
我在考虑使用JSON,你有什么看法?
谢谢你的时间.