$wpdb->update has finished saving trigger?
After an insert, the ID generated for the AUTO_INCREMENT column can be accessed with: $wpdb->insert_id Last sentence is just copyed and pasted form the codex.
After an insert, the ID generated for the AUTO_INCREMENT column can be accessed with: $wpdb->insert_id Last sentence is just copyed and pasted form the codex.
Thank you for all the help Toscho! The issue was actually quite obvious after a night of sleep. I am using WP Native Dashboard. In case you don’t know what that is, it allows you to change the language of the Admin section of the site. Considering WP Ajax is considered to be admin, it’s … Read more
I realized that comment-reply.js is not loaded and it fixed the issue. Could someone explain? I have no idea what happened. So the fix was adding wp_enqueue_script( ‘comment-reply’ ); to my plugin code.
$.post(ajaxurl,{ action:’master_ajaxurl’, option: $(this).find(“option:selected”).val(), // use option also here }, function(data){ //adds the echoed response to our container // alert(data); $(“#details”).html(data); } ); Move action and functions into function.php file make some changes as commented add_action(‘wp_ajax_master_ajaxurl’, ‘master_ajaxurl’); add_action(‘wp_ajax_nopriv_master_ajaxurl’, ‘master_ajaxurl’); function master_ajaxurl() { $myOpt = $_POST[‘option’]; // use option instead of data echo bringDetails($myOpt); die(); } … Read more
There are tons of questions about using Ajax, so your question could be easily marked as duplicated but I see so BIG mistakes that I can’t say to you that the question is duplicated without explaining your mistakes. The Ajax in WordPress is handled in admin-ajax.php file, wehre you correctly sent the ajax request (see … Read more
You have to use the admin-ajax handler to do the AJAX call. Replace file.php in var url = “file.php”; with yoursite.com/wp-admin/admin-ajax.php?action=simple_ajax And in your plugin / functions.php file, add add_action(‘wp_ajax_nopriv_simple_ajax’,’process_simple_ajax’); //for non logged in user add_action(‘wp_ajax_simple_ajax’,’process_simple_ajax’); //for nlogged in user function process_simple_ajax(){ $data = $_REQUEST; // retrieve your submitted data wp_send_json($data); // return the processed … Read more
“How can I prevent unexpected output from reaching the browser/interfering with my AJAX response?” The Problem Something in your installation is generating “unexpected output,” that is, it’s creating content or data which should not be there if WordPress is running smoothly. This could imply a misconfigured server environment, a faulty WordPress installation, a bad database … Read more
If you’re releasing this as a plugin, you absolutely must use the AJAX API. It’s super easy: /** * Handle the request and return the result. */ function alumni_process_request() { global $wpdb; // All your processing code from your original question, except for loading WordPress! return $data; } /** * AJAX handler for the “alumni” … Read more
The main issue I was having is that when an ajax request hits not all hooks are being loaded. I used this code: $return = array(); foreach( $GLOBALS[‘wp_actions’] as $action => $count ) { $return[“message”] .= $action . “, “; } wp_send_json($return); This showed me the hooks that were running before and I got it … Read more
Solve cors problem using rest api or ajax