i am facing a problem with get requests.
what am trying is very simple. an input field where the user input a text, the text fet send to a php page via get request and the page echo it back, the result is displayed in a div.
codes:
page code:
Code: Select all
<html>
<input type="text" id="name"/><input type="button" id="btn" value="echo"/>
<div id="disp"></div>
<script type="text/javascript" src ="http://code.jquery.com/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src ="ajax.js"></script>
</html>
ajax.js code (it handles the get request
Code: Select all
$('#btn').click(function(){
var name=$('#name').val();
// alert (name); <- this alert is executed but it stops here
$.get("http://127.0.0.1/time.php", { msg : name }, function(data){
$('#disp').text(data);
});
});
Code: Select all
<?php
echo $_GET["msg"];
?>