I have 2 scripts, submit.php
and display.php
.
I want to be able to load submit.php
, click the submit button & the result
div to display 123
.
Right now, it just reloads my page. I'm not getting anything from my Console so stuck how to debug.
Can someone take a look and provide assistance?
submit.php:
<form>
<input type="submit" value="Submit" name="display" id="display">
</form>
<div id="result"> </div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$("#display").click(function() {
$.ajax({
url: 'display.php',
type: 'GET',
dataType: "html",
data: {
"id": "123",
},
success: function(data) {
//called when successful
$('#result').html(data);
},
error: function(e) {
//called when there is an error
//console.log(e.message);
}
});
});
</script>
display.php:
<?php
$id = $_GET['id'];
echo $id;
?>