Kodları lütfen aşağıdaki butonları kullanarak renklendirin. Örnek: <php> echo "Selam Dünya"; </php>
Yardım
karakter kaldı

Ajax Post - İlk Kaydı Sadece Gönderiyor

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="../js/jquery-1.6.1.js"></script>
</head>
<script type="text/javascript">


 function ekle(){

	var id = $("input[name=input_id]").val();
	var img = $("input[name=input_img]").val();

	var veriler = "friend_id="+id+"&friend_img="+img;
	
	alert(veriler);
	
	$.ajax({  
    type: "POST",  
    url: "takip.php",   
	data:veriler,
    success: function(msg){  
   
  
	if(msg == 'OK')
	{ 
	
	   $.notifyBar({ cls: "success", html: "Eklendi"});
	}  
	else  
	{  
	    $.notifyBar({ cls: "error", html: "Hata"});
		return false;
	}  
   

   } 
   
  }); 

}//bitiş

$(document).ready(function(){
 

	
	
});
</script>
<?php 
require "C:/wamp/www/site/dbconfig.php";

$online = mysql_query("select * from users where status =1");

while($row=mysql_fetch_array($online))
{
$id = $row['id'];
$image = $row['img_name'];


echo '<form name="veysel" id="fform" method="post" onsubmit="return false;" action="">';
echo '<input type="text" id="id" name="input_id" value="'.$id.'" />';
echo '<input type="text" id="img" name="input_img" value="'.$image.'" />';
echo '<input type="submit" value="'.$image.'" onclick="ekle()" />';
echo '</form>';
}


?>

<body>
</body>
</html>



takip.php




<?php 
require "C:/wamp/www/site/dbconfig.php";

print_r($_POST);

$friend_id = $_POST['input_id'];
$friend_img = $_POST['input_img'];

$insert = mysql_query("insert into tbl_kisi (id,img) values ('$input_id','$input_img')");


if(mysql_num_rows($insert))
{
echo "olmadı";
}
else
{
echo 'OK';
}
?>
+0
-0
Cevaba KatılıyorumKatılmıyorum
Cevap Yaz Yorum Yaz Arşivime Ekle Takip Et

Cevaplar

  • veyselkoparal adlı üyenin fotoğrafı
    12 yıl önce yazılmış
    7 cevap - 11 soru
    Hangi Butona tıklar isem en üstteki ilk kaydı gönderiyor...
    • siyahbeyaz adlı üyenin fotoğrafı siyahbeyaz
      <button type="button" id="ekleyy">Ekle</button>

      html kodun bu sekilde duzeltıp

      javascript function ekle yi kaldırıp yerıne
      $("#ekleyy").click(function(){
      
      });


      olarak denermisin. birde altaki document.ready icine almamışsın kodu...
      12 yıl önce yazılmış
    • veyselkoparal adlı üyenin fotoğrafı veyselkoparal
      ama ekle() fonksiyonunu çalıştırıyor ki , çalıştırmasa idi post etmezdi ,,, yinede bir deneyeyim
      12 yıl önce yazılmış
    • veyselkoparal adlı üyenin fotoğrafı veyselkoparal
      fark yok
      12 yıl önce yazılmış
  • deja_wu adlı üyenin fotoğrafı
    12 yıl önce yazılmış
    24 cevap - 5 soru
    echo '<form name="veysel" id="fform" method="post" action="javascript:void(0)"';
    echo '<input type="text" id="id" name="input_id" value="'.$id.'" />';
    echo '<input type="text" id="img" name="input_img" value="'.$image.'" />';
    echo '<input type="submit" value="'.$image.'" onclick="ekle()" />';
    echo '</form>';
    


    birde bunu dener misin :)