Ajax call to php function doesn’t work PHP code

It looks like the MBAjax.ajaxurl and MBAjax.admin_url are probably not set. If it can’t post to the correct WordPress handler, then you will probably get a 404 page HTML returned instead of the PHP function return value. You can test by hard-coding the ajax url to url: “/wp-admin/admin-ajax.php”, and see if that fixes things. Secondly, … Read more

Ajax call not working anymore

I figured it out using this previous post: Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php Basically, I had added an action to prevent subscribers from seeing certain wordpress pages. function limit_subscriber_access() { $redirect = home_url( “https://wordpress.stackexchange.com/” ); if ( ! ( current_user_can( ‘manage_options’ ) || current_user_can( ‘edit_posts’ ) )) exit( wp_redirect( … Read more

ajax multiple Values

Thanks to give me the advise to work with JSON. I Think i get it now. Perhaps someone could look over it? Here My Code Button: <div id=”div3″> <button id=”rob-wp-ajax-vorlage-button”>ok</button> </div> My PHP Code function load_my_ajax_vorlage() { wp_enqueue_script( ‘my_custom_js’, plugins_url( ‘ajax-vorlage-script.js’, __FILE__ ), array(‘jquery’), false, false ); } add_action(‘wp_enqueue_scripts’, ‘load_my_ajax_vorlage’); add_action( ‘wp_footer’, ‘load_my_ajax_vorlage’ ); add_action(‘wp_enqueue_scripts’, … Read more

Ajax call from Plugin using Class

All the code is correct except the way i was calling. I created a different method for __construct and then called it on the plugin it self so the scripts and styles get hooked before the templates. In my template i called the class again and the methods i need it. I no longer constructed … Read more