Yes, i know how IF statement works i just couldn't remember how.
I have 3 alternatives to run the api but only the first one does make an actual valid request but doesn't retrieve any information or may be misconfigured.
Requesting to 127.0.0.1 works but not in this url
Code: Select all
<html>
Is Spammer? <a id='demo'></a><br>
Last seen: <a id='query'></a>
<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myObj.email.appears;
document.getElementById("query").innerHTML = myObj.email.lastseen;
}
};
xmlhttp.open("GET", "https://api.stopforumspam.org/api?json&email=email@hotmail.com", true);
xmlhttp.send();
</script>
</html>
Requesting to 127.0.0.1 doesn't work nor the alert popup
Code: Select all
// requires jQuery
<script>
var json = (function () {
$.ajax({
type: "GET"
url: https://api.stopforumspam.org/api?json&email=email@hotmail.com,
dataType: "json",
success: function (data) {
json = data;
}
});
return json;
})();
</script>
<script>
alert(json);
</script>
Request to 127.0.0.1 doesn't work but the code has worked in another project
Code: Select all
// requires jQuery
function isspammer(email) {
var API_Url = "https://api.stopforumspam.org/api?json&email=";
$.get(API_Url + email, function(jsonObj){
if (jsonObj.length > 0) {
var list = "The list:<br><br>";
jsonObj.forEach(function(element) {
list += element + "<br>";
});
document.write(list);
}
$(document).ready(function(){
isspammer("email@hotmail.com");
});
}
Any help will be great, probably i'm just missing something...
Thanks