I need to submit a form via ajax (not json) to another domain but keep getting the error
XMLHttpRequest cannot load http://some.other.domain/. Origin http://localhost:8081 is not allowed by Access-Control-Allow-Origin.
Is there a way to “fix” this?
$.ajax({
type: "POST",
dataType: "text/html",
data: $("#surveyForm").serialize(),
crossDomain: true,
url: "http://some.other.domain",
processData: false,
error: function (jqXHR, textStatus, errorThrown) {
},
success: function (response) {
}
});
Your best option might be to set up a proxy server. You can’t use JSON-P because you are doing a form POST, and you can’t use CORS because you don’t control the headers on the remote domain.