I know this is So simple code but somehow its not working. What I what to do is to call GET API of :
https://api.upcitemdb.com/prod/trial/lookup?upc=4011200296908
I want to call this HTML by using JavaScript or Jquery. I have tried many things but its not working. Following code which I have applied but its not working :
<!DOCTYPE html>
<html>
<body>
<button type="button" onclick="loadDoc()">Request data</button>
<script>
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      alert("responseText" + this.responseText);
    } else {
      alert("Error");
    }
  };
  xhttp.open("GET", "https://api.upcitemdb.com/prod/trial/lookup?upc=4011200296908", true);
  xhttp.send();
}
</script>
</body>
</html>I also have tried to call same API with Jquery by using Ajax. Following is code for the same :
<!DOCTYPE html>
<html>
<body>
<header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</header>
<button type="button" onclick="loadDoc()">Request data</button>
<script>
function loadDoc() {
    $.ajax({
        url:"https://api.upcitemdb.com/prod/trial/lookup?upc=4011200296908",
        success:function(response){
          alert(response);          
        },
       error: function() {
        alert("Error");
        }
    });
}
</script>
</body>
</html> 
     
    