mockJSON
mockJSON - 可以依照既定或自己定義的 data set, random 回傳一組回來
MockJSON is a plugin for jQuery that can hijack JSON and JSONP requests and respond with randomly generated JSON data. Completely random JSON would be pretty useless of course, so you can specify a JSON template for each request. On the right you see an example of such a template and some generated output.$(document).ready(function() { var template = { "fathers|5-10":[ { "married|0-1":true, "name":"@MALE_FIRST_NAME @LAST_NAME", "sons":null, 'daughters|0-3':[ { "age|0-31":0, "name":"@FEMALE_FIRST_NAME" } ] } ] }; $.mockJSON(/mockme\.json/, template); $('#template').text(formatJSON(template)); $.getJSON('mockme.json', function(json) { $('#result').text(formatJSON(json)); }); });
沒有留言:
張貼留言