Code Issue
-
My Js file containts:
jQuery(document).ready(function($) { $('#placeorder').click(function(){ alert('6'); $.ajax({url:MyAjax.ajaxurl, action: 'my_action'}); }); });
and php file:
// embed the javascript file that makes the AJAX request wp_enqueue_script( 'my-ajax-request',get_template_directory_uri() . '/js/countclicks.js', array( 'jquery' ) ); // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php) wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); add_action('wp_ajax_my_action', 'my_action_callback'); add_action('wp_ajax_nopriv_my_action', 'my_action_callback'); function my_action_callback() { echo "<script Langauage=\"Javasacript\">"; echo ("alert(\"Invalid user, please try again\.\");"); echo "</script>";die(); }
function file include above PHP file as:
include_once(‘order_submit_inc.php’);But I can’t execute my PHP function on button click. I want to call this from page template.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Code Issue’ is closed to new replies.