1

I have a need for using the POST/validateEmail to do client side ajax validation on an email address prior to submitting data from a webform/webcollect to a data extension.

source: http://code.exacttarget.com/apis-sdks/rest-api/v1/address/validateEmail.html

Using the json protocol and the https endpoint i setup an ajax post but i'm seeing the response - Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.exacttargetapis.com/address/v1/validateEmail. This can be fixed by moving the resource to the same domain or enabling CORS. I added $.support.cors = true but I still am unable to read the response from this validateEmail. Can you provide information on how to enable access for cross domain post to this resource? Even trying to host the code within an ExactTarget landing page has not worked.

var emailData = {
   "email": "help@example.com",
   "validators": [ "SyntaxValidator", "MXValidator", "ListDetectiveValidator"]};

$.ajax({
    type: 'POST',
    url: url,
    async: false,
    crossDomain: true,
    data: JSON.stringify(emailData),
    contentType: "application/json",
    dataType: "json",
    success: function(data) {
        console.dir(data);
    },
    error: function(e) {
       console.dir(e.message);
    }
});
  • Hey Adam...Thanks for your help with formatting my code's blockquote. Would you be able to comment on this question? – user18476 Apr 7 '15 at 16:35
  • are you using APEX,VF? – Pranay Jaiswal May 30 '16 at 5:34
1

There is not going to be a way to get around Cross-Origin Request Blocked in order to access that domain from client-side JavaScript. Requests to this API would need to come from the server. A processing page on your server would need to be created which calls this API that can then be accessed via JavaScript.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.