Mockjax HTTP Error Code

Is it possible to mock HTTP error codes and other header information using mockjax?

$.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); } }); 

Alternatively, is there another library that can?

+4
source share
1 answer

You can set the error status code to "status":

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

Source: https://habr.com/ru/post/1489935/


All Articles