My javascript code not working I dont get any errors but When I click submit button nothing happens I am fallowing a video tutorial I have watched twice but I cant find out what is wrong here
This is index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
function gonder() {
// $('#sonuc').html("bekle");
$ajax({
type:"post",
url:"ajax.php",
data:$('ferman').serialize(),
success:function (msg) {
$('#sonuc').html(msg);
}
});
}
</script>
</head>
<body>
<form id="ferman">
<input type="text" name="ad" >
<input type="text" name="soyad" >
<input type="button" value="gonder" onclick="gonder();">
</form>
<div id="sonuc"></div>
</body>
</html>
this is ajax.php
<?php
$ad=$_POST["ad"];
$soyad=$_POST["soyad"];
echo "ad $ad soyadınız $soyad";
?>
Khallister :
It seems the main problem is here:\n\nFix\n\n$('ferman').serialize(),\n\n\nto\n\n$('#ferman').serialize(),\n\n\nIt's just simple mistake, really nothing to explain, considering that you used # id selector correctly on #sonuc.\n\nfunction gonder() {\n// $('#sonuc').html(\"bekle\");\n $.ajax({\n type:\"post\",\n url:\"ajax.php\",\n data:$('#ferman').serialize(),\n success:function (msg) {\n $('#sonuc').html(msg);\n }\n });\n}\n\n\nUpdate: As squint mentioned in the comments, and I missed it, there is a missing . in ajax call, should be $.ajax.\nThanks to squint to point that out anyway.\n\nNote: There is no need to change input type from button to submit while we are making an ajax call.\n\nCheers :)",
2016-09-25T15:00:12