var requestURL = 'http://jsrun.net'; var option = { 'list|10': [{ 'id|+1': 1 }] }; Mock.mock(requestURL, option); $.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>
* { margin: 0; padding: 0; font-size: 12px; } html, body { height: 100%; } #cmd { width: 100%; height: 100%; }