This question already has an answer here:
Why does my ajax not work?
These are my pages.
I'm using JQuery to check click event and using ajax to load the responder page.
What is wrong in this code?
index.php
<html>
<head>
<title>Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('#clicket').click(function() {
$.ajax({
url: 'res.php?rand=' + Math.random(),
type: 'GET'
success: function(results) {
alert(results);
}
});
});
});
</script>
</head>
<body>
<button id="clicket">Hi</button>
</body>
</html>
Responder page:
res.php:
<?php
echo "Worked!";
?>
UPDATE: I changed my javascript code above.
</div>