First of all, in your jquery event handler the action
parameter’s value should be the string after wp_ajax_
and wp_ajax_nopriv_
. So in your example the action
should be update_records
. So display_func
is wrong.
Then in line 3 of your php code here the echo
keyword should be removed.
So your php code should be like this:
function update_records(){
global $wpdb;
$id = $_POST['update_record'];
$db_updated = $wpdb->update( $wpdb->prefix.'contact_form',
array(
'names' => $_POST['update_name'],
'emails' => $_POST['update_email'],
'gender' => $_POST['update_gender'],
'age' => $_POST['update_age']
),
array( 'ID' => $id )
);
}
add_action( "wp_ajax_update_records", "update_records" );
add_action( "wp_ajax_nopriv_update_records", "update_records" );
Related Posts:
- Load more AJAX on WP Query
- Using AJAX to return search form results
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- Update Loop with Form
- Refine/Filter WP_Query Posts with jQuery or Ajax
- Load More Posts Button – AJAX
- Filter wordpress post categories with jquery/ajax and pagination?
- Change AJAX filter from POST to GET for URL Parameters
- Loading two different AJAX requests on two different pages
- Ajax (jquery) wp_query pagination returns -1
- WordPress AJAX Request returns 400
- WordPress live search and filter custom fields
- WordPress live search and filter
- Filter admin ajax data by url query
- Finding post ID dynamically on click
- WordPress conflict with multiple load more posts functions on click
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- How to solve this script problem in theme directory?
- Sorting Posts Based On Meta Value Using AJAX
- AJAX search function resets wp_query vars
- WordPress Ajax search filter on dropdown select
- Current post in AJAX call is always zero
- Query most popular terms by taxonomy over 2 week period
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- Ajax future single post query doesn’t work when NOT logged in
- Meta Query doesn’t works as espected
- Error with function in functions.php?
- Use Ajax To filter posts?
- how to get Nearby zipcode
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- A $_POST should occur when submit form but is not?
- AJAX Breaking Offset Argument In WP Query
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- Apply filters to main query instead of creating new one?
- Update query for wp_posts and wp_postmeta
- WP_Query offset is returning post from prevois loop
- How to use a dropdown to filter posts by custom field
- mysql query order by
- Does WP_Query ‘responds’ badly to empty arguments?
- Retrieve data from wordpress db via input and put those result in dropdown
- Live search from database table
- WP_Query with page_ids in arguments without a result
- WordPress Insert not working with ajax
- WP_query is not returning the expected result
- WordPress dynamic AJAX query
- ajax wp_query conditional tags not working
- I need to run a AJAX Fuction from within a WP_Query but only works on first item
- Query multiple meta key values for template
- Change post query onclick
- Add AJAX “Load more” on custom query block
- get_var is neither a string, integer, or array …?
- How to filter a static post page with ajax and $wp_query
- wpquery via ajax
- Display custom-post type based on the Title matching the current selected value
- How to pass the current content of $wp_query to a new page?
- wordpress mysql / wpdb ajax load more for terms help
- JOIN filter doesn’t work in WP_Query in wp-ajax calls
- SQL query injection with fifu image
- WordPress Ajax form filter | Search by title with ajax form, breaks the other filters
- Why when I using infinity scroll the one post loads over and over?
- Using Ajax and WP_Query to load more posts on category page fails
- Ajax filter with loadmore button
- Why last row deleted when refresh page
- WP Query – grouping posts by same meta key, adding together values from another key
- Woocommerce Get Orders By Meta Value
- SQL to join u3g_users & u3g_meta_value with repeating data
- Slick slider for post doesn’t display anything
- WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- INNER JOIN custom tables – SQL Query
- use mysql variable in a $wpdb->query to reindex a column?
- One of two similar WP Query is very slow
- Fix wp_term_relationships slow query in get_posts
- How to use jQuery validation to set the search bar to accept only a specific input?
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- WordPress Query optimaization for slow query
- Load WP Query with Ajax
- Sorting query_posts() with a complex orderby filter
- Case insensitive ORDERBY in wpquery
- remove_action – pre_get_posts – does not restore original query
- Query postmeta based on meta_value, return array of post_id
- Order Posts By Custom Field That is an array of objects
- Multiple wpostmeta.meta_key
- Order & Orderby clause not working with custom query
- Is not using admin-ajax to ajax submissions okay?
- Is instantiating WP_Query not possible within an admin Ajax call?
- Slow query when selecting with large meta query or post__in
- WordPress custom query by archive title
- Show All with Isotope
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- Ajax not updating to database
- modifying the loop multiple times with arguments passed through ajax to wp_query
- Fetching $_POST from Page Template into functions.php
- WP_Query for liked posts is showing all posts if none are liked
- WP_Query always returning the last custom post
- Declare inline background image in functions.php
- How to get query results for the next page
- I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views
- WordPress WP_Query offset parameter not working with search parameter
- Why is $wp_query fetching nothing?