To make a working HTTP request with fetch API you have to do something like this.
const form = new FormData();
form.append('action', 'make_appointment');
form.append('post_title', 'hola como estas');
const params = new URLSearchParams(form);
fetch(ajaxSettings.ajaxurl, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'no-cache',
},
body: params
}).then(response => {
return response.json();
})
.then(response => {
// read data here
console.log(response);
}).catch(err => {
console.log(err);
});
Related Posts:
- How can I make an Ajax login form work with FORCE_SSL_ADMIN enabled?
- Help making my pagination plugin better
- How to pass JavaScript variable to PHP in wordpress widget?
- Add image to post from external URL
- jQuery AJAX call not executing in Plugin
- Problem running Ajax in WordPress
- Errors while using ajax from external wordpress page
- I can’t access wordpress functions from an ajax php call
- Built in admin ajax hooks?
- delete_user_meta Delete one value out of array
- How to use wp-ajax in wp-cron
- Calling shortcode in wp_localize_script strips result
- how to use ajax to display from database and load more in wordpress plugin
- Ajax with jQuery UI dialog not working
- Shortcode in AJAX popup
- AJAX image upload with a upload progress bar using media_handle_upload
- jQuery Plugin to use WordPress functions in AJAX request
- $wpdb working with ajax but showing ajax error instead of success
- Why none of the plugins that have ajax doesn’t work in my website?
- Why do plugins that cause ‘unexpected output’ create AJAX problems?
- AJAX button run function
- How to put JQuery/Ajax inside shortcode?
- WordPress Ajax Posting from App
- Using a custom plugin to capture input data via Ajax and PHP
- Ajax contact form widget plugin data not insert in database
- woocommerce_package_rates not fired when wordpress woocommerce accessed as non ajax
- Why WordPress plugin url ajax doesn’t work?
- AJAX in plugin wp_send_json() sending html
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Ajax call returning 0
- Ajax fail and get 504 error
- Ajax Search Lite: Customize Autoscroll
- Create tabs in admin options page from custom post type loop
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- AJAX call – failling to call do_action
- What are the Best Practises When Using AJAX in Plugin Development?
- Does having more than 30 Admin Ajax affects site performance (plugin)?
- Submit Form data to another page via Ajax (WordPress Way)
- plugin shortcode not working on ajax request call
- wordpress add_action() issue in ajax call
- How to display checked posts on another page over AJAX? (like comparasion style)
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Ajax Plugin Not Echoing Response
- where do I send my ajax calls
- Ajax save data to database on document ready, no data being saved
- WordPress Ajax code is not Working
- don’t call ajax if not plugin page
- How to get specific string/value from an array? php [closed]
- woocommerce search by sku and title ajax
- Where Should i write the code for wordpress ajax voting?
- How to request admin-ajax.php correctly when wordpress URL and site URL are different?
- Passing PHP Variables to AJAX Loaded Pages
- How to include my Ajax calls in one function instead of calling different ones every time?
- Call ajax on the frontend
- Using AJAX to run SQL statement and populate dropdown
- Ajax request sends url rather than data
- grab or load text on demand
- best way to run a php script away from the template?
- admin-ajax.php 500 error when new users try to register
- Ajax call not working in wordpress through a plugin
- Send Array from JS to php file then insert it in wp database through a plugin
- Ajax 400 error when used inside a plugin
- Strange admin-ajax / CSS / $_SESSION issue
- wc_get_template_part doesnt display the content [duplicate]
- In a plugin, How to update a json file using ajax
- Cannot pass value variable to WP AJAX functions
- JS working when used normally but not in wordpress
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- How to avoid the 403 Forbidden error in a WP Plugin with Ajax and PHP
- Conditionally load public and admin code with AJAX working on both sides
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- How to disable/enable PHP plugin functionality based on a TinyMCE toggle-button
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Get shortcode attribute for AJAX call
- ajax voting for custom post type
- Why can’t I call a function from inside my registered AJAX function?
- Conditional Fields depending on checkboxes
- Ajax call fails and returns [object Object]
- WordPress environment not loading properly
- wordpress ajax pagination object value does not change
- WordPress Feedback popup with date saved into table
- Javascript not working
- Ajax specific template not loading in replacement of index.php
- WordPress ajax not working in registration
- Ajax return 0 in plugin – ajax only used in wp-admin
- What’s the preferred method of writing AJAX-enabled plugins?
- using jquery serialize in ajax operation for plugin
- ajax request not returning the result
- How do I convince this button to do something when it is clicked?
- Like/Dislike Bar not working when updating
- My AJAX API plugin isn’t working
- ajax sends data to plugin
- Trouble Removing Plugin [closed]
- Help me with my first very basic plugin
- Ajax not working for logged in users
- Jquery post responses 500 error after some time and lastly an 503 error
- Ajax button “Load more” is not loading correct language version posts for logged out users
- Inline AJAX script passing variables to PHP
- wordpress admin-ajax bad request 400
- Not applying update field (acf) in my plugin