WordPress Cron not triggering a Jquery action
-
I am trying to create an automatic emailer which sends reports once per month. I already created a cron event which triggers every minute (for testing purposes only) and it works fine.
Now the problem that I am facing is I’m currently using a plugin which generates and exports a csv file, I want to reuse it’s function to generate a report then send it to email. This exporter plugin is designed to trigger once a button is clicked.
Here’s my current code for the cron scheduled event function.
function update_db_hourly() { global $wpdb; $wpdb->insert( 'rtl21016_cron', array( 'test' => 'value1' ) ); testing(); }
And here’s the testing function which contains some jquery codes.
function testing(){ global $wpdb; $wpdb->insert( 'rtl21016_cron', array( 'test' => 'value2' ) ); ?> <input type="button" value=" Export Report " id="auto_report" class="button" style="display:block; position:absolute; z-index:100; top:500; right:100" onclick="window.open('?page=exports-reports&report=4&action=export&export_type=csv&export_source=custom_monthly_reports','temp_report_window');"> <iframe name="temp_report_window" id="temp_report_window" class="temp_report_window"></iframe> <script>console.log("Send RTL reports...");jQuery('#auto_report').trigger('click');</script> <?php global $wpdb; $wpdb->insert( 'rtl21016_cron', array( 'test' => 'value3' ) ); }
The jquery event in the function works whenever I manually call the function
testing()
. But whenever the cron scheduled event triggers it doesn’t work. the$wpdb->insert
codes that you see there is for debugging purposes only, they all works just fine on all scenarios.Any idea about this? Thanks in advance
- The topic ‘WordPress Cron not triggering a Jquery action’ is closed to new replies.