var requestURL = 'http://jsrun.net';
var Random = Mock.Random
// // var option = {
// // 'news|10': [{
// // 'id|+2': 1,
// // 'title': Random.ctitle(3, 5),
// // 'con': Random.csentence(30,50),
// // 'tag': Random.ctitle(),
// // "time": Random.date('yyyy/MM/dd')
// // }]
// // };
// var option = {
// 'news|10':
// [{
// 'id|+2': 1,
// 'title': Random.ctitle(3, 5),
// 'con': Random.csentence(30, 50),
// 'tag': Random.ctitle(),
// "time": Random.date('yyyy/MM/dd')
// }]
// }
var news = [];
var tags =['科技','娱乐','体育','国际','NBA','科技','财经','汽车','时尚','游戏']
for (var i = 0; i < 10; i++) {
// var option = {
// 'title': Random.ctitle(3, 5),
// 'con': Random.csentence(30, 50),
// 'tag': Random.ctitle(),
// "time": Random.date('yyyy/MM/dd')
// }
var random = Math.floor(Math.random()* 11)
news.push({
'id|+1': 1,
'title': Random.ctitle(5, 15),
'con': Random.cparagraph(),
'tag': tags.random,
"time": Random.date('yyyy/MM/dd HH:mm:ss')
})
}
Mock.mock(requestURL, news);
$.ajax({
url: requestURL,
dataType: 'json',
success: function (data) {
var code = '<pre>$code</pre>';
code = code.replace('$code', JSON.stringify(data, null, 2));
$('#cmd').html(code);
}
});
<div id="cmd"></div>