ali ak ali ak - 3 years ago 231
Ajax Question

My javascript code not working

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">
<meta charset="UTF-8">
<script type="text/javascript" src=""></script>
<script type="text/javascript">
function gonder() {
// $('#sonuc').html("bekle");
success:function (msg) {



<form id="ferman">

<input type="text" name="ad" >
<input type="text" name="soyad" >
<input type="button" value="gonder" onclick="gonder();">
<div id="sonuc"></div>

this is ajax.php


echo "ad $ad soyadınız $soyad";

Answer Source

It seems the main problem is here:





It's just simple mistake, really nothing to explain, considering that you used # id selector correctly on #sonuc.

function gonder() {
//   $('#sonuc').html("bekle");
         success:function (msg) {

Update: As squint mentioned in the comments, and I missed it, there is a missing . in ajax call, should be $.ajax. Thanks to squint to point that out anyway.

Note: There is no need to change input type from button to submit while we are making an ajax call.

Cheers :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download