The action: 'ajax_contact'
part in:
var data = $form.serialize();
console.log(data);
$.ajax({
url: ajax_contact.ajaxurl,
dataType: 'json',
action: 'ajax_contact',
data: ajax_contact.data,
is most likely the cause here, that your ajax request is failing.
Move the action part into the data set instead.
Since you’re serializing the form data, you could try to add:
<input type="hidden" name="action" value="ajax_contact" />
into your form.
Also make sure the data attribute:
data: ajax_contact.data,
is getting the serialized data, but not the undefined ajax_contact.data
.
You can try with manual json string instead for testing.
ps: also consider using nonce for extra security.
Related Posts:
- WordPress AJAX File Upload – FrontEnd
- jQuery and AJAX Not working with Select Form Element
- Registration e-mail check with AJAX
- Accept AJAX call with serialized form data
- Frontend Post with JQuery AJAX to Php Issue
- Converting a working AJAX form to work with WordPress
- jQuery forms & updating info
- Is not using admin-ajax to ajax submissions okay?
- $_POST empty in using new php file added to theme
- jQuery form plugin, submit in the wordpress way
- JSON parsing error syntax error unexpected end of input
- Pass request headers in a jQuery AJAX GET call
- jQuery Ajax error handling, show custom exception messages
- How to send multiple data fields via Ajax?
- My javascript is returning this error: $.ajax is not a function
- jQuery AJAX submit form
- Jquery Ajax Posting JSON to webservice
- Ajax TypeError: $.POST is not a function
- TypeError: $.ajax(…) is not a function?
- XML Parsing Error: not well-formed in FireFox but good in Chrome
- Ajax Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
- How to fix the ‘Missing required request header. Must specify one of: origin,x-requested-with’ Ajax Error
- What’s the point of the X-Requested-With header?
- How to get a cross-origin resource sharing (CORS) post request working
- jQuery Form Validation before Ajax submit
- jQuery – Illegal invocation
- Clear form fields with jQuery
- FormData append not working
- jQuery’s .on() method combined with the submit event
- Get a form action/url with jquery
- Twitter Bootstrap Modal Form Submit
- Validate form before submit jquery
- jQuery ajax error function
- How to manage ajax calls and JSON in wordpress
- ajax stopped working when not logged in?
- Using jQuery to delete data stored in wp_options
- How to add a ” waiting” icon for an ajax in WP frontend?
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- What is the simplest ajax upload plugin or script to be used with wordpress?
- AJAX nonce with check_ajax_referer()
- Creating Ajax backend for Specialised Page Template? Should admin-ajax.php be used?
- WordPress Ajax URL for function in functions.php
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- wp_mail script with jQuery post
- Ajax call does not activate callback function
- AJAX call returns 0
- AJAX function returning -1
- call shortcode in javascript
- WP set auth cookie using Ajax is not saved to browser
- How to link WordPress heartbeat to ajax form
- How to pass both action and formdata in wordpress ajax?
- jquery & ajax getting data to php in wordpress
- AJAX returns response 0
- jQuery AJAX form validation
- Passing a varible from jQuery to PHP
- Proper way to load a single post via Ajax?
- Basic WordPress AJAX Call
- Add X meta box inputs based on form at top of meta box, how to do it right?
- Trying to get single posts to load on the front page via ajax
- ajax call in wordpress front end
- AJAX post into pop-up div
- Bind to WPSetAsThumbnail
- Ajax not firing properly using Firefox, but works in Chrome
- Using AJAX to return search form results
- jQuery Ajax() doesn’t work when the page is accessed as a WordPress template page
- Appending anchor tag to next post
- POST from jQuery to PHP
- How to Use JSON With AJAX?
- wp_localize_script, variable is not defined in jquery
- How to load whole WordPress pages dynamically with AJAX/jQuery like this following website?
- Using wp_ajax and wp_ajax_nopriv hooks
- WP REST return value to error function from Request
- Creating custom AJAX requests
- How to pass jQuery ajax URL value
- Cannot access elements of json object
- Basic ajax call in WordPress
- jQuery Validate wp_editor
- Updating User Profile with AJAX not working
- how to get the comment ID in the front end when the REPLY button is clicked?
- Gravity Forms not loading under https, jQuery is not defined
- Auto Load New Posts
- Gravity list field override and adding javascript [closed]
- Admin wp_ajax hook returning 0
- jQuery Plugin to use WordPress functions in AJAX request
- How do I setup nested repeatable option fields?
- wp_ajax() question.. not using wp_enqueue_script?
- wp_ajax unauthenticated and authenticated
- Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author
- WordPress ajax function parameter value not being passed
- WordPress Ajax not function as I expect… what’s wrong?
- wp_verify_nonce not working
- Tags in WordPress 3.2
- php ajax problem – weird 301 responses!
- jQuery Ajax passing empty parameters to my function?
- WordPress customizer refresh screen after save
- Is there a restriction in WP on the use of jQuery load function?
- Loading posts via AJAX in a hidden div with updated URL?
- Making the wordpress login form a jQuery dropdown
- How to get a value from PHP in Jquery through Ajax
- Not sure why wp_ajax isn’t working?