I have the below code and am trying to pass through data with a GET HTTP Request using Jquery and Ajax. When typing in "Example" in the text box and clicking "Go", I would expect "example" to come back in the feedback div. Nothing is being returned though. I would appreciate any help on why this would not be working. Thanks.
File name is "trial.php"
<body>
<script type="text/javascript" src="jquerycode.js"></script>
<script type="text/javascript" src="ajax.js"></script>
<input id = "string" type = "text" />
<input id = "button" type = "button" value = "Go" />
<div id = "feedback"></div>
</body>
File name is "ajax.js"
$('#button').click(function()
{
var string = $('#string').val();
$.get('file.php', { input: string }, function(data) {
$('#feedback').text(data);
});
});
File name is "file.php"
<?php
if(isset($_GET['input']))
{
$string = $_GET['input'];
echo strtolower($string);
}
?>
print_r($string), also check what do you get inside the success callback of theGETrequest by doingconsole.log(data)oralert(data);