ajax function executes the main plugin file
-
Hello,
Every time I make an ajax request the main file (plugin-name.php) gets rerun,
plugin-name.phpnamespace pluginname; $number = rand(0,10); require_once(NAMEPLUGIN_DIR.'/ajax.php'); add_action('wp_ajax_randNumber','pluginname\ajax\getNumber');
ajax.php
namespace pluginname\ajax; function getNumber(){ global $number; echo $number;// The result varies, }
The result varies, because plugin-name.php is executed again.
How can I fix this without using the database?
thank you very much
Viendo 1 respuesta (de un total de 1)
Viendo 1 respuesta (de un total de 1)
- El debate ‘ajax function executes the main plugin file’ está cerrado a nuevas respuestas.