I'm trying to echo something via Ajax but I'm not getting any output. So I would add a pair of error handling to see what is working wrong.
How can I add simple error handling code to see where the error is?
page.html
<body>
<input id="name" type="text" />
<input id="button" type="button" value="Load" />
<div id="feedback"></div>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="ajax.js"></script>
</body>
page.php
<?php
if (isset($_GE['name'])) {
echo $name = $_GET['name'];
}
?>
ajax.js
$('#button').click(function () {
var name = $('#name').val();
$.ajax({
url: 'page.php',
data: {
name: name
},
success: function (data) {
$('#feedback').html(data);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
});