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)
- username_exists() function can’t be access without logging in
- How to loop through JSON data in wordpress WP REST API
- WP API V2 returning Invalid User ID
- Security – Ajax and Nonce use [closed]
- Export all post from database to JSON only when the database gets updated
- PHP calling AJAX function that relies on passed PHP function values not working
- Looking for a better way to handle an ajax script that pulls in post data on click
- How to add default images into theme customizer image control?
- Can’t use get_results() in ajax query
- Debugging PHP object during Ajax call in WordPress
- WordPress Ajax Data problem
- Access/update database with jQuery
- Passing jQuery value using Ajax to a page template
- admin-ajax.php responding with 0
- ajax_object is not defined when ajax calls the function
- Page Reloads Before AJAX Request Finishes
- Why is this Ajax not working?
- How to prevent those PHP variables from being cached on WordPress?
- Use ajax from function.php
- Ajax return code 400
- Create dynamic pages from external JSON data without storing in Database?
- Vagrantpress + composer
- get post based on category chosen in drop down – The ajax method
- How to make drop down post title
- ajax, right way to do it and make it works?
- WordPress ajax doesn’t display object method on jQuery .change() function
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Problem with custom plugin using AJAX to pull info from php file
- Gutenberg block – Save PHP function’s output as HTML?
- Call a PHP Function with Multiple Parameters that is outside the AJAX Handler
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- WordPress, AJAX and pre_get_posts using conditional tags
- wp_enqueue_script seperately for each shortcode
- Refresh table data with Ajax
- Input data from email form not going to JSON file
- Setting value of session with Ajax not working
- [jQuery]Adding shortcode
- Display parent and child taxonomies in separate drop down select fields
- Ajax contact form return 0
- AJAX – Returning Two JSON Objects with One PHP Function
- unable to use ‘new WP_Query’ in AJAX call
- admin-ajax Firing Error 400 When Logged In
- is_user_logged_in() not working in AJAX validation call
- Add Ajax Hooks and Call from Custom Template PHP
- WordPress Ajax Always returning 0
- Problem with AJAX in wordpress plugin
- set post limit at load more ajax wordpress
- Woocommerce with Lazy Load php and ajax
- Can I make get_users() query global?
- How to use AJAX to call php page with parameter
- My jQuery Ajax form submit is still refreshing page?
- javascript variable to wordpress php variable
- entire JS folder not loading in a WP theme
- Output votes to div dynamically in wordpress
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- How to clone all WordPress Rest API end points
- PHP error with a shortcode: “no suitable wrapper” for file_get_contents
- How to use AJAX in WordPress in MYSQL query?
- calling admin-ajax.php from admin-ajax.php
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- WordPress Custom Add To Cart Button with AJAX
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- jquery & ajax getting data from php in wordpress . admin-ajax.php returns 400
- Settings API form – submit with AJAX
- Load more posts using AJAX based on posts inside WP_Query
- register_block_type is not working properly
- Submit remote form to wordpress REST API and save data to custom post type
- WooCommerce REST API AJAX Auth – 401 response
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- AJAX numerical pagination problem in TwentyFifteen-child theme
- Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error
- Why my Ajax events are no longer detected after dynamic change of shortcode content
- Contactform7: display results from CURL
- Top Authors list by highest post views with Ajax pagination
- Need help to create WordPress page that decodes a text file and publishes it in JSON format
- ajax polling with admin-ajax.php
- Include search tags and users in my search results system
- Complex PHP for json_encode > how to handle/output right?
- Ajax not updating to database
- Ajax Load more CPT via shortcode
- Apply filters when loading post via ajax
- MySQL query in WordPress with AJAX
- Is custom behaviour possible when asynchronously uploading?
- Search in particular category in wordpress
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- Data inserted in database, but ajax calls error function
- I am unable to fetch json data from wp_db
- Detecting IP Address of someone using ‘copy’ function [closed]
- Correct way to perform a GET to another PHP file hosted on wordpress
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- AJAX returning blank result