- // The response is always the same
- $.mockjax({
- url: '/restful/fortune',
- responseTime: 750,
- responseText: {
- status: 'success',
- fortune: 'Are you a turtle?'
- }
- });
- $.getJSON('/restful/fortune', function(response) {
- if (response.status == 'success') {
- $('#fortune').html('Your fortune is: ' + response.fortune);
- } else {
- $('#fortune').html('There is a problem with the request');
- }
- });
转载请注明:谷谷点程序 » jquery mockjax使用实例