You need to add the ajax callback action on your plugin file or themes functions.php like as below:
add_action( 'wp_ajax_fetch_data', 'fetch_data_callback' );
add_action( 'wp_ajax_nopriv_fetch_data', 'fetch_data_callback' );
then you need to put all the featch_data.php code inside the callback function ‘fetch_data_callback’ like as below:
function fetch_data_callback(){
//your function code goes here
wp_die() // need to add end of the function
}
In Jquery
var action = 'fetch_data';
$.ajax({
url:"<?php echo admin_url( 'admin-ajax.php' ) ?>",
method:"POST",
data:{action:action, minimum_price:minimum_price, maximum_price:maximum_price, modoconf:modoconf, modoserv:modoserv, sub1:sub1, sub2:sub2},
success:function(data){
$('.filter_data').html(data);
}
});
Related Posts:
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Check javascript file Proper way in functions.php
- How to create popup same as wordpress popup feature
- wordpress add_action() issue in ajax call
- Load CSS files in header of Bones theme?
- Jquery POST Ajax Return null data in wordpress
- JS working when used normally but not in wordpress
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Ajax, jQuery and WordPress
- Load css classes after using ajax calls
- Javascript as Jquery Function Call?
- force enqueue script to be first in order of prominence
- Help making my pagination plugin better
- How do I make my wordpress page more friendly for mobile viewers?
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- jQuery AJAX call not executing in Plugin
- 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
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- Ajax with jQuery UI dialog not working
- Check if email address exists front end with AJAX in a plugin
- JQuery not working in my plugin [closed]
- Using custom JS plugins with WordPress?
- Form isn’t inserting data into database with ajax plugin
- Best approach to fetch data from wp options to js file or php file
- wordpress site | All-in-one-cufon IE Issue
- Change upload folder for a CPT
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- How to load wp_editor via AJAX
- Redux Framework: Page freezes on typing in Editor
- How can I inject options into an select tag inside the widget form?
- Display wordpress post’s in popup?
- Using color picker in plugin, does input attribute order matter?
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- Using window.onload with Ubermenu
- how to insert data in wordpress table usnig jquery ajax
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- “Conflict” with jQuery (or its plugins)?
- How to display checked posts on another page over AJAX? (like comparasion style)
- How to get specific string/value from an array? php [closed]
- Why does my jQuery plugin show up as text in WordPress?
- JQuery needs to be defined in , but Gravity Forms is defining it in the
- Disable submit button order
- How to include my Ajax calls in one function instead of calling different ones every time?
- Using AJAX to run SQL statement and populate dropdown
- Ajax request sends url rather than data
- Plugin Admin panel checkbox unchecked after submit
- Custom Plugin scripts from admin working in frontend
- admin-ajax.php 500 error when new users try to register
- Ajax call not working in wordpress through a plugin
- Send Array from JS to php file then insert it in wp database through a plugin
- wc_get_template_part doesnt display the content [duplicate]
- How do I reinit WordPress plugins dynamically using jS?
- login form should redirect to register page for in 1st login next time it should redirected to home page
- Trouble with AJAX using GET
- Get the link title attribute and send it google analytics as custom label via google tag manager using beehive pro for WordPress
- Calling PHP function with AJAX
- Cannot pass value variable to WP AJAX functions
- How to properly enqueue jQuery knob on WordPress without conflict?
- How to get a specific string from a url
- Does anybody know how to insert a complete jquery plugin into a wordpress elementor-page?
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- WordPress site hamburger menu toggle not working
- AJAX update fails for public/non-admin users
- checkout stripe with plugin contact form
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- How to disable/enable PHP plugin functionality based on a TinyMCE toggle-button
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Conditional Fields depending on checkboxes
- Help with customising love it plugin (use within foreach)
- show-hide based on select option jquery wordpress
- Speed issues because of CSS & JavaScript
- Javascript in plugin not working
- 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 doesn’t pass variables to the php function in the plugin
- How do I convince this button to do something when it is clicked?
- Like/Dislike Bar not working when updating
- jquery-issue: cannot load the basic jquery
- Possible jquery / library conflict in plugin usage
- Why won’t the Comprehensive Google Map Plugin load?
- get_option include in my adsense
- How do I output user_registered time in my correct timezone?
- Ajax in Plugins: returns the whole page
- Element works, but not on wordpress site [duplicate]
- FacetWP: Plugin breaks button/modal functionality inside searchable content area
- TypeErrors with Yoast, jQuery in conflict?
- Count div with class (.length) only shows 0 [closed]
- Jquery post responses 500 error after some time and lastly an 503 error
- How do I call an action hook into wp_ajax hook callback function
- Select posts from list and add them in a new list