var form0 = document.forms[0];
form0.onsubmit = function(e){
alert("form submitted");
var email = form0.elements["email"].value;
var url = "https://bpi.briteverify.com/emails.json?address="+email+"&apikey=my-key&callback=emailResult";
jsonp(url, function(data) {
if (data.status != "valid") {
e.preventDefault();
alert("INVALID EMAIL");
}
});
}
function jsonp(url, callback) {
var callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random());
window[callbackName] = function(data) {
delete window[callbackName];
document.body.removeChild(script);
callback(data);
};
var script = document.createElement('script');
script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + callbackName;
document.body.appendChild(script);
}
This code snippet functions correctly in Chrome and Safari, but experiences issues in Firefox. Even though the 'Form Submitted" alert is displayed, subsequent actions do not occur.
The question remains whether this discrepancy is a result of a specific Firefox compatibility issue or a potential mistake within the code.