Your are pointing to a non existing AJAX file.
$.ajax( {
// ...
url : '/path/myfile.php',
// ...
} );
WordPress has a predefined file for that:
admin_url( 'admin-ajax.php' )
When you are running public queries, then you need to add it to
wp_localize_script( 'your-script-handle', 'yourJavaScriptAccessibleObject', array(
'ajaxurl' => esc_js( admin_url( 'admin-ajax.php' ) ),
) );
If you are just running admin facing calls, then you can even leave that out and simply use
ajaxurl
in your JavaScript file as the variable is prefilled. In case you have a single setup, you can use this hack for Apaches .htaccess file.
Keep in mind that you want to secure your AJAX calls by using a NONCE:
'_ajax_nonce' => wp_create_nonce( 'your-script-handle' ),
Related Posts:
- AJAX search posts and pages
- woocommerce search by sku and title ajax
- How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?
- User Following System
- What’s the preferred method of writing AJAX-enabled plugins?
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- 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
- Thumb rating for wordpress – top user
- ‘Lazy loading’ list of posts with pagination
- Find out if request is for custom post type archive before query runs
- How to include admin-ajax when loading external javascript
- Fatal error: Uncaught Error: Call to undefined function get_userdata()
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- Ajax with jQuery UI dialog not working
- Shortcode in AJAX popup
- How can I process xml file on upload?
- ajax front-end increment views on click
- Why none of the plugins that have ajax doesn’t work in my website?
- medoo framework in WP plugin
- Accessing GET variable named ‘error’
- Check if email address exists front end with AJAX in a plugin
- How can i list random post from multiple category?
- WooCommerce get_price returning wrong price when used via ajax
- Accessing post’s meta data based on user’s click of a post
- How to Create a Custom Panel and Fields in Post Page [Plugin]
- Theme is Causing Ajax Conflicts for a plugin I cant identify it
- wordpress, search form using ajax
- Search for categories
- Best place for if/else piece of code related to custom plugin?
- How to call WordPress function other files
- 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 can I inject options into an select tag inside the widget form?
- Init plugin again after ajax call finish
- Display wordpress post’s in popup?
- How to create a custom shortcode based on the layout?
- Using color picker in plugin, does input attribute order matter?
- how to insert data in wordpress table usnig jquery ajax
- ACF: post query, hide duplicate values [closed]
- Redirect to another page using contact form 7? [closed]
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- How to get a list of bundled products using wp_query in woocommerce
- WordPress Apply filter in plugin causes 500 internal error
- Meta query for comparing two dates
- where do I send my ajax calls
- Replacing global wp_query
- Using WordPress to build membership Page
- Proper way to handle admin-ajax calls
- Ajax object not defined – JS file is in plugin folder
- WordPress subfolder installation AJAX Problem
- 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!
- Delete data from custom table when deleting a post
- Searching a tab/space delimited text file based upon form criteria and returning a ‘record’ into a word press results page
- 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
- adding dynamic/multiple slug values in ‘option_none_value’
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Is it possible to custom set query for a WordPress REST API response?
- Only return taxonomies that are linked to a category & product
- How to add specific posts to specific pages in WordPress?
- 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
- Update User Meta Via Ajax
- Compare Ajax Data Results
- Frontend AJAX Request causes Error: ‘Call to undefined function add_action’
- ACF Query result in a new td (echo)
- Ajax Load More on Hierarchical Categories
- cURL do not mimic click
- Multiple Meta key in search
- wp_schedule_event function reference
- Creating new option (add_option) from AJAX – Settings API
- How can I use wp_ajax_response for front-end error reporting?
- 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
- 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
- Second foreach loop breaking (Posts2Posts)
- Plugin constructor called multiple times
- Ger posts from similar tags and categories
- wp_query for more fields plugin
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- Include subtitle display to slideshow
- Trouble After Update, Removing Plugin
- Jquery post responses 500 error after some time and lastly an 503 error
- Select posts from list and add them in a new list
- Show the author only own types of publications. (JetEngine, Elementor)
- Ajax response from Media Selection does not update ALL information more than once