I have to build a WordPress plugin which gives out HTML for an AJAX call. However, because of the server environment I cannot use the traditional admin-ajax.php
.
Someone told me that I could build a custom page using url-rewrite ex: /my-ajax-calls/
So when I send a request to that page it would be:
jQuery.get("/my-ajax-calls/param1/param2/",...);
Then I could use param1
& param2
and give the appropriate HTML.
I know how to build plugins, how do I rewrite the URL to connect it with a method that generates the HTML?
You can simply target to a custom file when using
wp_localize_script()
. Just – in the third argument-array – setajax_url
to whatever file you want to target.