This will not work due to the “same-origin policy” unless that server you are trying to reach specifically allows these type of requests with something like Access-Control-Allow-Origin: *
. You can read the documentation on MDN in order to get more information about this topic.
From my tests, the server will also need another header configured namely the Access-Control-Allow-Headers
so if we combine those two options a valid setup might look like this:
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type, Accept, Authorization, X-Requested-With
Related Posts:
- Is there a JavaScript API? How to access public and private data in JS?
- AJAX request from Chrome Extension to WordPress Website
- fetching via fetch/ajax gutenberg block data from third party
- wp_localize_script escaping my url – fix or alternative
- Most performant way of fetching remote API data?
- How to add WP API and JS featured image attachment
- Implementing an AJAX POST API call in wordpress
- Exposing data using a custom WordPress API
- Use WP admin AJAX url to hide API key
- How can I call an api before user login
- How to submit a button automatically after every scheduled hours?
- Ajax in a settings page (update_option is undefined)
- gettext does not translate when called in ajax
- Execute one AJAX request after another AJAX request finished
- Ajax and autocomplete
- admin-ajax.php vs Custom Page Template for Ajax Requests
- Load tinyMCE / wp_editor() via AJAX [duplicate]
- Saving (Updating) Post / Page Edits With AJAX
- How to correctly load wordpress in a non WP script for AJAX request
- Minimal WordPress load for only `get_option` to work (because ajax…)
- Why is admin ajax reloading my page
- Plupload in metabox – AJAX action not working in Class
- Admin Ajax always return 0 on form submit
- CPU usage: AJAX and Heartbeat API on admin pages
- Confused on AJAX submit form through page template
- Ajax call in wordpress not working for subscriber user in front site
- add_action(‘wp_ajax_[action name]’, myfunction) problem
- Can part of my WordPress website be headless?
- Nonces, AJAX, script variables & security in WordPress
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- Why would admin-ajax.php redirect to the home page for logged out users?
- Insert wp_editor on front-end with AJAX?
- Admin Ajax and HTML5 Formdata
- Buddypress: Load Ajax Without Template Pack [closed]
- Woocommerce Ajax Add cart not working
- wp_ajax_nopriv_xxx is not firing on one site, works on all others. -1 for logged out users
- WP_User_Query ignoring ‘meta_query’ arguments
- Ajax Modal Flickers When Opened Multiple Times
- Increased CPU load due to admin-ajax.php spam
- Ajax image upload with media_handle_upload and form.js
- Can’t get result from sql using ajax result
- Theme Customizer – Conditional Controls
- Edit a different page in WP Customizer
- Get the_content with ajax
- WordPress AJAX – how to return true or false in the callback function
- Admin ajax error 400 when passing select value to populate another select
- WordPress Ajax POST Error 403 admin-ajax.php
- Ajax post returning full html page as response
- Which allowed API hooks work to add wp_ajax action?
- Pass additional parameter with async upload
- AJAX request randomly stop working and returns error 400
- Sending variable from ajax on form submit
- Performance optimization of tree like structure
- WordPress search results with Ajax, get_post_type() not working
- Audio TAG Not using MediaElement When Page is loaded through ajax
- Is it secure to use admin-ajax.php in front?
- Best way to use ajax front-end?
- Ajax calls from the theme directory
- How to pass parameters from jQuery ajax into PHP function?
- ajax is returning 0
- How to add ajax url to js using wp_add_inline_script()?
- merge wp rest api query to get posts per category does not work
- use jQuery.load() to include a php file in a div, wp_query() is part of php file
- WP AJAX post filter > do something with empty value
- How to jQuery Ajax show new data from successful insert?
- Redirect after saving form; and yet use wp_die()
- ajaxt returning object object [closed]
- Load more posts (Ajax) in tabbed sidebar on single.php
- Something strange with ajax
- admin-ajax.php returns 0 even when the post status code is 200 OK
- Why is the file not uploading to the server?
- Get localize of a loaded javascript
- Merge PDF files from post custom fields(ACF) into one PDF file and respond back the created PDF file, WordPress(AJAX Request)
- REST public POST giving 403 forbidden nginx
- Query data after an Ajax insert
- How to get next and previous post into ajax formed modal windows?
- How to prevent multiple post with same meta value being created simultaneously in WordPress (with ajax)
- Content including hooks inside wp-settings.php are being called twice in WordPress
- Problem when sending file via ajax
- wp_verify_nonce not working on the mobile device
- Can’t GET Variable from AJAX URL
- JS global variable doesn’t update
- 404 error custom post type rest api
- How to update cart total after AJAX success
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Change button text after ajax db update
- Jquery wrap permalink in a data-attribute?
- How do I display posts of a specific day?
- Load .php file into div using ajax
- Native WordPress Video Shortcode Not Working After Post is Loaded via Ajax
- Ajax Function call is always returning 0 in front end(without plugin) [closed]
- Ajax live search, “No products found” when the title contains apostrophes and quotations
- Using AJAX for dynamic settings pages
- Speeding up admin-ajax.php
- admin ajax is not working for non logged in users
- wp_localize_script not create variable in head section
- AJAX admin Internal 500 error Failed to Upload
- Class property not visible inside ajax callback function?
- how reduce fetch/XHR response time
- wordpress ajax bad request 400