You can achieve this using wp_localize_script
$myData = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
);
wp_localize_script( "myScript", "alm_localize", $myData );
NOTE: myScript
should be the handle of a script which has been registered using wp_register_script
Related Posts:
- What’s the preferred method of writing AJAX-enabled plugins?
- Help with 4.6. Attachment response object in JSON API plugin
- Loading shortcode with ajax
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Ajax Load More and Masonry: is it possible to load admin-ajax.php in the front end?
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- ‘Lazy loading’ list of posts with pagination
- How to include admin-ajax when loading external javascript
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Why is my ajax call refreshing the page?
- Admin-ajax.php is dying “0” without processing function
- How to remove an Ajax action
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- Get Plugin Information from Multiple Sites Externally
- How to add pagination to wpbakery grid?
- Check if email address exists front end with AJAX in a plugin
- Why plugin ajax response is -1?
- WordPress Ajax Callback
- plugin ajax to external php file always return null
- WooCommerce get_price returning wrong price when used via ajax
- When to use action hooks and plugins
- Form isn’t inserting data into database with ajax plugin
- AJAX search posts and pages
- wordpress, search form using ajax
- jquery not calling php function
- Best place for if/else piece of code related to custom plugin?
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- WordPress Integration with Google Groups
- Best place to load wp_ajax_the_ajax_hook action in plugin
- jQuery.post not working within shortcode – WordPress Ajax
- How to load wp_editor via AJAX
- How can I inject options into an select tag inside the widget form?
- Init plugin again after ajax call finish
- Using color picker in plugin, does input attribute order matter?
- How to handle cookies from a WordPress plugin on a cached page?
- wordpress file upload with ajax when site is ajaxyfi
- AJAX search as you type? [duplicate]
- WordPress api call using wp-ajax returns error 400
- how to insert data in wordpress table usnig jquery ajax
- Using wpdb without loading all plug-ins via wp-load.php
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Call plugin with php function
- Is it safe to use admin-ajax.php in the frontend?
- Create WordPress posts from JSON array using plugin in admin
- Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin
- where do I send my ajax calls
- Using WordPress to build membership Page
- Proper way to handle admin-ajax calls
- Using custom php file for ajax url inside plugin
- Ajax object not defined – JS file is in plugin folder
- WordPress subfolder installation AJAX Problem
- How to request admin-ajax.php correctly when wordpress URL and site URL are different?
- WordPress API functions not working at AJAX functions.php call
- Passing PHP Variables to AJAX Loaded Pages
- wp_ajax action responds with 0
- Why AJAX response 0!
- Ajax request sends url rather than data
- grab or load text on demand
- admin-ajax.php 500 error when new users try to register
- Send Array from JS to php file then insert it in wp database through a plugin
- AJAX call inside plugin class is not getting to it’s response function
- How do I reinit WordPress plugins dynamically using jS?
- Trouble with AJAX using GET
- Adding LOAD MORE on a page
- JS working when used normally but not in wordpress
- Conditionally load public and admin code with AJAX working on both sides
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Ajax call to php function doesn’t work PHP code
- admin-ajax.php returning 0
- Get shortcode attribute for AJAX call
- Update User Meta Via Ajax
- Compare Ajax Data Results
- User Following System
- Why can’t I call a function from inside my registered AJAX function?
- Frontend AJAX Request causes Error: ‘Call to undefined function add_action’
- Ajax Load More on Hierarchical Categories
- cURL do not mimic click
- Creating new option (add_option) from AJAX – Settings API
- How can I use wp_ajax_response for front-end error reporting?
- WordPress Feedback popup with date saved into table
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Not getting result using ajax on wordpress
- Javascript not working
- Ajax specific template not loading in replacement of index.php
- WordPress ajax not working in registration
- AJAX login without a plugin does not work. when add a action to function.php
- AJAX doesn’t pass variables to the php function in the plugin
- ajax request not returning the result
- How do I convince this button to do something when it is clicked?
- Plugin constructor called multiple times
- My AJAX API plugin isn’t working
- ajax sends data to plugin
- Trouble After Update, Removing Plugin
- Jquery post responses 500 error after some time and lastly an 503 error
- Ajax button “Load more” is not loading correct language version posts for logged out users
- Inline AJAX script passing variables to PHP
- Select posts from list and add them in a new list
- wordpress admin-ajax bad request 400