JSFiddle - React, Tailwind, and code Playground

by Dedi Wibisono

HTML

<input type="checkbox" onchange="showData(this)"> select

JavaScript

var a = '';
var b = '';
function ajax_test(){ 
  $.ajax({ 
    url:"https://swapi.co/api/people/1",
    success: function(data, status, xhr){
    
      a = data.height;
      b = a + " lala"
    }
  });
}  
function showData(tha){
	if (tha.checked) {
	  alert(b);
	  }
	
}
ajax_test();//init