1

I'm trying to submit a form on my website (xyz.com) to Salesforce. When I click submit, I get this error

Access to XMLHttpRequest at 'https://webto.salesforce.com' from origin 'https://www.xyz.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I've whitelisted the origin URL (https://www.xyz.com) and doesn't seem to work.

HTML:

<form class="myForm" action="https://webto.salesforce.com" method="POST">
    <input type="text" class="myInput">
</form>

<div class="msg">Sent!</div>

JS:

$('.msg').hide();

$.ajax({
    type: 'POST',
    url: $('.myForm').attr('action'),
    data: $('.myForm').serialize(),
    success: function(response) {
       $('.myForm').fadeOut();
       $('.msg').show();
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.