Ali Kubur
Ali Kubur

Reputation: 39

jQuery ajax error when data fetching

I am using bootstrap 3.2.0 and jQuery. I can't get fetch data via jQuery and PhP

function postolayi(){
  $.ajax({
    type:'POST',
    url:'giriskontrol.php',
    data:$('#girisForm').serialize(),
    success:function(cevap){
      $("#uyari").html(cevap) 
    }
  })
}

index.php

<form class="form-signin" method="POST" id="girisForm">
  <input  id="isim" name="isim" type="text" class="form-control" placeholder="isim" required autofocus>
  <input name="sifre" type="password" class="form-control" placeholder="şifre" id="sifre" required>
  <button class="btn btn-lg btn-primary btn-block" type="submit" onclick="postolayi();">
  Giriş Yap</button>
</form>
<div class="alert alert-warning" id="uyari"></div>

giriskontrol.php

<?php
$POST["isim"] = $isim;
echo $isim;
?>

I can't fetch data. Please somebody help.

I changed as

<?php
$isim = $POST["isim"];
echo $isim;
?>

But still not working.

Upvotes: 0

Views: 79

Answers (3)

Adam
Adam

Reputation: 344

You need to switch your assignment on your php page to

<?php
$isim = $_POST["isim"];
echo $isim;
?>

Upvotes: 0

Ende Neu
Ende Neu

Reputation: 15783

You are overwriting the post variable here:

$_POST["isim"] = $isim;

What you probably wanted was:

$isim = $_POST["isim"];
echo $isim;

Upvotes: 1

ktzhang
ktzhang

Reputation: 4157

In your php file Switch:

$POST["isim"] = $isim;

with

$isim = $POST["isim"];

Upvotes: 0

Related Questions