Skip to content

Instantly share code, notes, and snippets.

@aaronjorbin
Forked from garyc40/enqueue-localize-js.php
Last active December 28, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjorbin/7470829 to your computer and use it in GitHub Desktop.
Save aaronjorbin/7470829 to your computer and use it in GitHub Desktop.
<?php
// embed the javascript file that makes the AJAX request
wp_enqueue_script( 'my-ajax-request', plugin_dir_url( __FILE__ ) . 'js/ajax.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', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment