Why write url: admin-ajax.php?

Learn ajax in Wordpress.
In some instances meet this code
 url: "/wp-admin/admin-ajax.php",
 method: 'post',

but they write that the handler is written in function.php
not exactly sure what to write url: "/wp-admin/admin-ajax.php"
if we write the handler functions.php
What happens if we don't write this url ?
April 19th 20 at 12:06
2 answers
April 19th 20 at 12:08
Here is the answer to Your question and all the future on this topic.
thank you! - oswald38 commented on April 19th 20 at 12:11
April 19th 20 at 12:10
Your js sends the data to the file processor, which is an input point. Think of it as an API endpoint. Because the request file functions.php you can not include it. But /wp-admin/admin-ajax.php is not include, there rises slightly lightweight version of WordPress which is designed only to take your submitted data, determine what action you want to use, and through this action to transfer the data to a handler that hangs on this action. And now, in functions.php you on this action Packed format wp_ajax_{$action} and wp_ajax_nopriv_{$action}is connected to your processor, which will accept the posted data, do with them whatever you need and return the response which in turn /wp-admin/admin-ajax.php going back to your js.

The link @Camille_OConner in more detail with examples. In General, edit the file /wp-admin/admin-ajax.php and some of the questions she will disappear.
thanks for the reply! - oswald38 commented on April 19th 20 at 12:13

Find more questions by tags WordPress