Here is the html and jQuery part:
<html>
<head>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
</head>
<body>
<script type="text/javascript">
$('document').ready(function(){
$('#submit').click(function(){
var username=$('#user').val();
$.post('http://localhost:8080/verify/comment.php',
{
user:username
},
function(return_data)
{
alert(return_data);
}
);
});
});
</script>
Username:<input type="text" id="user"/>
<input type="button" id="submit" value="submit"/>
</body>
</html>
comment.php
<?php
echo 'welcome';
?>
It displays an empty alert message.. I can’t get the value “welcome” in alert message……..
Any suggestion…….?
Ohhh… my eyes just went crazy rolling by looking at this code. So many things you are doing wrong… Where to start?
clickevent on thesubmitbutton, but for asubmitevent on the form.This should be working for you:
Here is your PHP, which echos a
json_encode()d string, for context (notice how we accessedreturned_data.messageon the above code: