One of our clients asked us to use Loqate data-verification platform to verify Emails by using jquery. I need to implement the code to Crownpeak. There is a simple code that is given from the Loqate platform but I couldn't make it work. I am kinda new at this so I need help to make it work and understand how the process works.
I have tried the below code but it didn't work.
$.post('https://api.addressy.com/EmailValidation/Interactive/Validate/v2.00/json3.ws', {
Key: KEY,
Email: any,
Timeout: 2000,
}, function(data) {
// Test for an error
if (data.Items.length == 1 && typeof(data.Items[0].Error) != "undefined") {
// Show the error message
alert(data.Items[0].Description);
}
else {
// Check if there were any items found
if (data.Items.length == 0)
alert("Sorry, there were no results");
else {
// PUT YOUR CODE HERE
//FYI: The output is a JS object (e.g. data.Items[0].YourId), the keys being:
distance = data.Items[0].frm_profile;
console.log(distance);
// name = data.Items[0].Name;
//YourId
//Name
//Description
//Distance
//Time
//Easting
//Northing
//Latitude
//Longitude
return distance;
}
}
}); EmailValidation_Interactive_Validate_v2_00(Key, Email, Timeout)
dim strUrl
dim objHttp
dim rst
'Build the url
strUrl = "https://api.addressy.com/EmailValidation/Interactive/Validate/v2.00/recordset.ws?"
strUrl = strUrl & "&Key="& Server.UrlEncode(Key)
strUrl = strUrl & "&Email="& Server.UrlEncode(Email)
strUrl = strUrl & "&Timeout="& Server.UrlEncode(Timeout)
set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.Open "GET", strUrl, false
objHttp.Send
set rst = Server.CreateObject("ADODB.Recordset")
rst.Open objHttp.ResponseStream
if rst.Fields.Count=4 then
if rst.Fields(0).Name="Error" then
Err.Raise rst.Fields(0), "Webservice Error", rst.Fields(1)
end if
end if
set EmailValidation_Interactive_Validate_v2_00 = rst
end function