You don’t need to specify datatype in your AJAX call. Also, WP handles AJAX a bit differently, primarily:
$('#filter_evenement').submit(function(){
jQuery.ajax({
url:ajaxurl,
type:"POST",
data : {action: "evenements_filter_function", val1: "value1", val2: "values2"},
success:function(data){console.log(data);
var dataArray = jQuery.parseJSON(data);//parse JSON
},
fail: function( jqXHR, textStatus, errorThrown ) {
}
});
});
data has to contain action which specifies the WP AJAX handler function in the backend. You can also pass all values you need to send here (e.g val1, val2) Your evenements_filter_function() is not utilizing any data from AJAX call, it’s just sending a response. But to access the values you’d check $_POST['val1'].
Related Posts:
- Passing JSON data from WP Query into AJAX causing NULL errors
- Creating a Multi-Level Associative Object Using AJAX
- Retrieve Json data and create multiple pages with it
- Can’t pass var from php wp_ajax into ajax script : result undefined or null
- How can i send id of the currently posted form data through json response in custom wordpress plugin?
- AJAX Filter WHILE Loop not working WordPress
- Result from wp_send_json adds line feed
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- Woocommerce – how can i add items to cart using onclick – multiple items at once with custom prices
- how to make custom ajax handler?
- [jQuery]Adding shortcode
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- Display parent and child taxonomies in separate drop down select fields
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Plugins not working on AJAX requests
- Fetching instagram api not working on wordpress
- Fancybox type popup window that’s not an iframe
- Using Select HTML in Bootstrap Popovers
- How to disable controls in theme customizer?
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- how to update and display an option without reloading the page
- How do I Import / Upload Files with jQuery AJAX?
- WordPress admin-ajax.php 400 bad request
- WordPress Ajax Call inserting data but success response false
- Loading php file with AJAX in WordPress frontend
- wp ajax return 0
- Ajax contact form return 0
- WordPress plugin: render only page content using ajax call
- AJAX – Returning Two JSON Objects with One PHP Function
- Pull GetOption() variable into jQuery dynamically created html
- Get the URL of the page from which an ajax request has been launched within ajax callback
- JSON REST API WordPress only showing first 10 categories
- unable to use ‘new WP_Query’ in AJAX call
- admin-ajax Firing Error 400 When Logged In
- AJAX button action in foreach
- is_user_logged_in() not working in AJAX validation call
- Unset session variable on page reload / setup but exclude AJAX
- Add Ajax Hooks and Call from Custom Template PHP
- WordPress ajax-action failing because of newline in response
- Making an AJAX call to refresh a table
- HTML escaping data with ajax requests
- WordPress Ajax Always returning 0
- Using data sent via AJAX in multiple functions on a WP plugin
- Problem with AJAX in wordpress plugin
- load ajax using admin-ajax.php
- Ajax button not working
- Function won’t run onclick using Ajax
- How to keep track of when a vote is cast?
- WordPress plugin admin page – using WordPress function in linked php file
- Load Posts on Click via Ajax into a DIV
- set post limit at load more ajax wordpress
- Use value from Ajax call in PHP function
- Woocommerce with Lazy Load php and ajax
- How to deal with too many $_POST variable conditions from ajax request at backend? [closed]
- Simple AJAX notification when the new post is added to the database
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Short code template + ajax
- Ajax filter button display all posts
- Can I make get_users() query global?
- Compare $_POST returned values with term array
- Is it possible to create new user from external form using REST API?
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- WordPress REST API register_rest_route give a 500 error
- How to use AJAX to call php page with parameter
- Get related product based on subcategory selected from category id with ID 142
- A $_POST should occur when submit form but is not?
- When echo follow Ajax button inside Ajax pagination template not working?
- My jQuery Ajax form submit is still refreshing page?
- jQuery Ajax PHP function call returning [object Object]
- admin-ajax GET response bad request
- Shortcode to pull posts
- Ajax search shows all results when user empties input?
- Why i can’t get custom fields value or post ID via Ajax?
- Calling PHP Scripts in Ajax that are in PHP Snippets
- javascript variable to wordpress php variable
- Post not populating for custom post type based on category selection
- entire JS folder not loading in a WP theme
- SOAP Request/Parsing XML From wp_send_json_success
- Output votes to div dynamically in wordpress
- Get uploaded image and attach it to the new post
- Cannot access $wpdb, comes back NULL
- Admin-ajax php not working on new wordpress version
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- WP_Query with AJAX returning empty array
- Incrementing PHP variable onclick to display posts by month
- How to clone all WordPress Rest API end points
- Proper way to use WordPress function with AJAX PHP file
- Errors being created by admin-ajax.php
- Loading Posts & Category with Ajax
- PHP error with a shortcode: “no suitable wrapper” for file_get_contents
- How to use AJAX in WordPress in MYSQL query?
- Simple jQuery AJAX Request fails to run PHP Script
- Convert canvas to image and upload image to server
- How to get post category list as select in front-end?
- Live search from database table
- Processing ajax call to php to insert into mysql database
- PHP Warning: Missing argument 2
- Allow user to Upload image and manipulate it on the frontend
- Is there a hack for using is_page() within the function.php file?