I'm attempting to call a PHP file from Jquery. My website shows "hi" once my button is clicked so I know the click() function is being called but I don't get a response from my test.php file. Furthermore, my php file loads without error when called independent from this script.
<html>
<head>
<script language="JavaScript" type="text/javascript" src="jquery-2.1.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#submitButton').click(function(){
//var theName = $( "#name" ).val();
//var theID = $( "#transaction" ).val();
alert("hi");
$.ajax({
url: "test.php?name=Charlie&transID=1234",
type:'get',
success: function(data){
alert(data);
}
});
}
)
});
</script>
</head>
<body>
<form action="" method="POST">
<input id="name" type="text" size="20" placeholder="Enter Your Name">
<input id="transaction" type="hidden" name="transactionID" value="12345">
<input id="submitButton" type="submit" name="submit" value="Call PHP">
</form>
</body>
</html>
PHP:
<?php
$name=$_GET['name'];
$id=$_GET['transID'];
echo("Thank you $name for transaction #:$id");
?>
Thanks,
Craig