steve-clarke
6/20/2018 - 1:48 AM

JS API Call

Use this to call API using JavaScript using button

$("button").on("click",function(){
      //console.log("hii");
      $.ajax({
        headers:{  
          "key":"your key",
          "Accept":"application/json",//depends on your api
          "Content-type":"application/x-www-form-urlencoded"//depends on your api
        },   
        url:"url you need",
        success:function(response){
          var r=JSON.parse(response);
          $("#main").html(r.base); //not needed in my case, but useful anyway
        }
      });
});