Skip to content

Instantly share code, notes, and snippets.

@vickonrails
Created January 23, 2018 13:47
Show Gist options
  • Select an option

  • Save vickonrails/fcc6b823c7e9aab8d451b75ee207bc98 to your computer and use it in GitHub Desktop.

Select an option

Save vickonrails/fcc6b823c7e9aab8d451b75ee207bc98 to your computer and use it in GitHub Desktop.
//index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Home page</title>
</head>
<body>
<button>Get data</button>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script type="text/javascript">
const btn = document.querySelector('button');
btn.addEventListener('click',getData);
function getData(e){
$.ajax({
url : '/users',
method : 'GET',
success : function(data){
console.log(data);
},
error: function(err){
console.log('Failed');
}
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment