Answer the question
In order to leave comments, you need to log in
Emulating Ajax responses?
Good afternoon.
The situation is as follows: the development of the front-end and back-end parts of the application are separated in time. Tell me the tools that could be used to emulate Ajax requests, responses, delays, errors, etc., so that you can test the interaction with the server, the work of preloaders, etc. in advance. tasks.
Answer the question
In order to leave comments, you need to log in
Wrap your work with Ajax in some kind of wrapper. Make two plugins for the wrapper: one will work for real, and the second will emulate asynchrony using setTimeout.
When the backend is ready, switch to the real one.
Keywords: Facade pattern, Dependency Injection
Create a subdomain and write a rewrite rule that passes everything to one single script. Write a script that produces pseudo-random JSON data. And test to your heart's content. Send all requests to this subdomain (don't forget to make a DEFINE), keeping the get-request parameters.
In the script, it’s enough to make a block with a delay, a block with the generation of normal data and a nonsense generator that works every 10% (make a garbage constant and name it MurphyConst). Forward to the test!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question