First try with ajax, please have patience.
<html>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
function hello() {
$.post("testCaseAjaxServerSide.php", { ola: "hello"}, function(data){
if (data) {
alert('the data is: '+data);
}
else {
alert('there were no data');
}
});
}
$("#inputAmigo").click(function(){
hello();
});
});
</script>
<form method="post" action="">
<input id="inputAmigo" type="submit"/>
</form>
</html>
On the server side I have:
if (isset($_POST['ola']))
{
echo "we got a post";
}
else
{
echo "no post buddy";
}
I’m always getting “there were no data”.
Any help please? 🙂
Thanks a lot,
MEM
Works for me if I prevent the submit button’s default behavior. Try changing the click function to:
or change your form so that you’re not using a submit button. Use a simple
<input type='button'>instead.You could also try using the jQuery form plugin.