Advertisement
bradtrivers

WordPress AJAX - Enqueue and create function

Nov 5th, 2012
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. /* Enqueue and localize javascript in functions.php */
  2. function directory_addfront_js(){
  3.   wp_enqueue_script('jquery_directoryFront', get_stylesheet_directory_uri().'/directory_front.js', array('jquery', 'jquery_quickselect', 'jquery_quicksilver'));
  4.   wp_localize_script( 'jquery_directoryFront', 'marconfAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );  
  5. }
  6. add_action( 'wp_enqueue_scripts', 'directory_addfront_js');
  7.  
  8. /* In functions.php create the "ajax" function to load the form that will called by javascript via ajax. */
  9. add_action('wp_ajax_loadPersonUpdateForm', 'loadPersonUpdateForm');
  10. /* Function to load the Person Update Form - ID 7 */
  11. function loadPersonUpdateForm() {
  12.    echo apply_filters('the_content', do_shortcode('[gravityform id="7" name="Please update this Person\'s information!" ajax="true"]'));
  13. //   $result = self::get_form("7", true, true, true, null, true, 1); //second method - produced same results
  14.   die($result);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement