Y
Y
Yuri Yerusalimsky2016-10-09 19:37:28
PHP
Yuri Yerusalimsky, 2016-10-09 19:37:28

How to properly organize testing of a PHP script handler for AJAX requests?

There is a page that, through JQuery, sends POST data to a PHP script, which, in turn, will check the received data for correctness. You need to make sure that the data is received and processed correctly. What is the best way to check this?
I personally see several ways:
1. Write the contents of the necessary variables to a text file each time it is accessed.
2. After a certain period of time, make an additional AJAX request that will receive the same list in response and display it in the console via console.log.
3. Replace all POST requests with GET and already "emulate" them by calling the PHP script directly and substituting the values ​​into the address bar.

It seems to me that everything described above is unprofessional and very primitive. What is the best way to proceed in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
imdeveloper, 2016-10-10
@link_web

On the client side in the debugger, when sending a video in the network tab, what data is sent when a button is clicked, for example. On the server side, you can do var_dump($_POST['variable']); and in the script itself where Ajax is sent to success or done, output the received data from the server to the console and everything will be visible there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question