Replies: 0
Is it possible to get around the CORS error when trying to submit to my form via a JQuery Mobile and Cordova hybrid application? Below is an example of my ajax request:
var form = new FormData();
form.append("your-name", name);
form.append("your-email", email);
form.append("your-phone", phone);
form.append("day-choice", daychoice);
form.append("artist-email", "myemail@gmail.com");
var settings = {
"url": "http://mywebsite.com/wp-json/contact-form-7/v1/contact-forms/622/feedback",
"method": "POST",
"headers": {
"Content-Type":"multipart/form-data; boundary=--------------------------471778788390597587895515",
"accept":"application/json"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax({ settings,
success: function(result) {
console.log("Hello World");
},
});
Below is the error from my browser when I try to test locally.
Access to XMLHttpRequest at 'file:///Users/path to project/wordpressCordova/platforms/browser/www/index.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
-
This topic was modified 55 minutes ago by mrawers.