Ajax Form Handle Action outside functions.php
-
Hi,
currently i’am using this code to handle my form submit via ajax request (included in the functions.php of my theme):
add_action('wp_ajax_form_booking', 'handle_form_booking'); add_action('wp_ajax_nopriv_form_booking', 'handle_form_booking'); function handle_form_booking() { die("so many stuff to do..."); }But this code will be loaded every time, on every page. Can i tweak this for performance reasons, best only loading in one specified template file? Like “pseudo”:
<?php /** * Template Name: Home * Template Post Type: page * * @package ... * @version ... */ add_action('wp_ajax_form_booking', 'handle_form_booking'); add_action('wp_ajax_nopriv_form_booking', 'handle_form_booking'); function handle_form_booking() { die("so many stuff to do..."); }… This code will return 0, every time. Not return the die();
Thanks.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Ajax Form Handle Action outside functions.php’ is closed to new replies.