Mockjax HTTP错误代码

比利·穆恩(Billy Moon)

是否可以使用嘲笑模拟HTTP错误代码和其他标头信息?

$.mockjax({
    url: '/some/webservice',
    dataType: 'html',
    responseText: '<div>Hello there</div>'
});

// Normal ajax request in your application
$.ajax({
    url: '/some/webservice',
    dataType: 'html',
    success: function(html) {
        alert('You said: ' + html);
    }
});

另外,还有另一个图书馆可以吗?

丹达佩雷拉

您可以在“状态”中设置错误的状态代码:

$.mockjax({
  url: '/restful/api',
  // Server 500 error occurred
  status: 500,
  responseTime: 750,
  responseText: 'A text response from the server'
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章