you can use FormData
an example:
let form_data = new FormData;
form_data.append('action', 'myAction');
form_data.append('first_name', 'my first name');
form_data.append('phone', 'my phone');
axios.post(myVars.ajax_url, form_data).then(function(response){
console.log(response.data);
})
Related Posts:
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- How to cache json with wp-super cache
- Is there a JavaScript API? How to access public and private data in JS?
- failed to load wp-admin/admin-ajax.php
- Are ‘wp_ajax’ and ‘wp_ajax_nopriv’ exclusive to authenticated and non-authenticated users?
- How to HTML5 FormData Ajax
- Get posts with ajax
- Ajax requests without JQuery
- Custom PHP endpoint for a plugin’s AJAX call
- How to link WordPress heartbeat to ajax form
- How can I get logged in user’s session data from admin-ajax?
- WordPress Ajax Login without page reload
- AJAX only works when I’m logged as Admin
- When using javascript to dynamically add a textarea, how can I render it as a tinyMCE editor (in wordpress)?
- Drag and drop multiple file upload using Ajax WordPress
- Custom ordering fails after AJAX post filter
- How to securely add an Ajax button to a WP Admin page?
- How to “Load More” posts via AJAX?
- Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php
- Prevent page reload after ajax form submission
- WordPress Ajax Getting Response “Null”
- admin-ajax return error 400 for Chrome/Edge but not Firefox
- Is it safe to manually sign a user in using AJAX?
- WordPress Admin AJAX Serialize
- Why a strange discrepency between get_current_user_id() when using AJAX versus output of document.cookie?
- Loading post template that contains a nested loop with ajax
- Long Polling: Stuck in while loop
- Show Post Content with AJAX
- Code run fast on a cronjob but slow with a do_action or ajax call
- update_post_meta using ajax
- How to export custom database data to excel file
- Ajax comment form submit on frontpage alerts success but no insertion
- How to update Comment post meta through an Ajax call
- ModSecurity && Admin Ajax: Server locking up
- Wp mail does not work when Ajaxed to
- MySQL select query with ajax
- Exposing data using a custom WordPress API
- Bad request 400 from custom ajax call
- Use WP admin AJAX url to hide API key
- Get response for check_ajax_referer
- WordPress ajax-action how to return content
- AJAX jQuery post frontend returning failed to load resource status 400
- ajax form is returning the dreaded “[HTTP/1.1 400 Bad Request” and a zero
- 400 Bad Request when sending XHR from React.js to admin-ajax.php
- How to check nonce lifetime value of plugins?
- How can I wp_send_json data?
- Making POST request with AJAX returns a 400 error (without jQuery)
- Load image src through Ajax by ID?
- Using get_theme_mod in php ajax form doesn’t work
- PHP session when called wp_ajax_nopriv
- What exactly does ‘authenticated’ mean for wp_ajax_nopriv?
- Use AJAX in a WordPress Plugin to Get Data From Custom Database?
- AJAX – SHORTINIT set to TRUE returns blank
- How to make image in TinyMCE clickable
- How to use Jeditable plugin with admin-ajax.php?
- Ajax mousedown call getting “cancelled” when clicking link
- WordPress Ajax Not Firing
- Get uploaded attachment width & height and attachment ID after upload them
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- Disabling ajax code that does a POST request that ends in a 400 error code
- Refresh checkout fields on add to cart with order bump
- Add Server Side validation in Ajax mail form
- Is it good practice to use REST API in wp-admin plugin page? [closed]
- How to prevent my external API call from being called by anyone but me (my site)
- Ajax not sending the data correctly- Multidimensional array
- get a bad request 400 on my ajax-admin.php file
- Registration form AJAX check for existing username (simple version)
- How to check Ajax request only when i opened the Notifications list?
- All WordPress AJAX calls always return 0
- Trigger action via button
- Syntax error on query_vars while handling with Jquery
- Want to send ajax request in wordpress to a custom file in plugin
- How to send the checkbox value to email
- Class called in template, AJAX not registering
- Same query in category.php and in function.php, but different result
- Sending email with wp_email and AJAX
- AJAX Call in Plugin Returns More than JSON
- Ajax take too long to return code
- problem when adding wp_editor with ajax [duplicate]
- Get wp-load.php PATH with wp_localize_script and JavaScript for plugin
- Ajax Form seems to post, but does not return
- Ajax request to admin-ajax.php and window.location.href
- Objects and get_post_meta() gives me 1 string for latitude and longitude
- Why can wordpress not find the actions I add in my constructor?
- delete attachment for one post without deleting actual attachment post
- Memberpress isn’t cooperating with WooCommerce
- where does my function output from load-* go?
- WordPress ajax requst returns zero
- wp_editor() in content that was loaded with ajax [duplicate]
- WordPress blocking polling request when signed into Admin
- Facebook Pixel + WooCommerce + AJAX = Confusion
- Send button using own contact form [closed]
- How to get data with Select AJAX PHP
- Add “load more” functionality to an AJAX response
- Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php
- weird Internal Server Error – no error log produced
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?
- Successful ajax call returns lots of whitespace and text of code with 0
- How to submit a button automatically after every scheduled hours?
- At what stage does wp_ajax hooks gets applied during WordPress request?