• 13-07-2016, 03:26:24
    #1
    Arkadaşlar, bir proje üzerinde çalışıyorum.

    Tek bir buton ile onclick yapmak üzere 2 veriyi nasıl gönderebilirim?

    Aşağıda bir şeyler yapmaya çalıştım ancak olmadı.

    Konuyla ilgili bilgisi olanlardan destek bekliyorum.

    <a onClick="baslat('.$veri1.','.$veri2.')">BAŞLAT</a>
    function baslat(veri1,veri2){
                $.ajax({
                    type:"POST",
                    url:"baslat.php",
                    data:  {"veri1": "veri1", "veri2": "veri2"},
                    beforeSend: function(){
                        $("#islem_konsolu").prepend('İşleminiz başlıyor...<br />');
                    },
                    success: function(msg){ 
                        $("#islem_konsolu").prepend('<b>'+msg+'</b><br />');
                    },
                    error: function (msg){
                        $("#islem_konsolu").prepend('<b>HATA</b><br />');
                    },
                    complete: function(){
                        $("#islem_konsolu").prepend('<hr /><?=$saat?><br />İşleminiz tamamlandı...<br />');
                    } 
                }); 
    }
  • 13-07-2016, 09:33:59
    #2
    Konuyla ilgili bilgisi olan yok mu? Projede en alakasız ve önemli bir yerinde tıkandım. R10+
  • 13-07-2016, 09:39:02
    #3
    En basit haliyle bu kod işinizi görecektir.

    <html>
    <head>
    	<meta charset="utf-8">
    	<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
    </head>
    <body>
    
    <a href="javascript:;" onclick="gonder('d1','d2')">Gönderici</a>
    <div id="response"></div>
    
    <script type="text/javascript">
    
    function gonder(d1, d2){
    	$.ajax({
    		type: "POST",
    		url: "post_adresi.php",
    		data: "d1="+d1+"&d2="+d2,
    		success: function(answer){
    			$("#response").html(answer); 
    		}
    	});
    }
    
    </script>
    </body>
    </html>
  • 13-07-2016, 10:52:11
    #4
    Teşekkür ederim, eline sağlık. Son halini de ben bırakıyım, ihtiyacı olan alıp kullansın.

    <html>
    <head>
       <meta charset="utf-8">
       <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
    </head>
    <body>
     
    <a href="javascript:;" onclick="gonder('d1','d2')">Gönderici</a>
    <div id="islem_konsolu"></div>
     
    <script type="text/javascript">
     
    function gonder(d1, d2){
       $.ajax({
          type: "POST",
          url: "result.php",
          data: "d1="+d1+"&d2="+d2,
                    beforeSend: function(){
                        $("#islem_konsolu").prepend('İşleminiz başlıyor...<br />');
                    },
                    success: function(msg){ 
                        $("#islem_konsolu").prepend('<b>'+msg+'</b><br />');
                    },
                    error: function (msg){
                        $("#islem_konsolu").prepend('<b>HATA</b><br />');
                    },
                    complete: function(){
                        $("#islem_konsolu").prepend('<hr /><?=$tarihsaat?><br />İşleminiz tamamlandı...<br />');
                    } 
       });
    }
     
    </script>
    </body>
    </html>
    PsdBul adlı üyeden alıntı: mesajı görüntüle
    En basit haliyle bu kod işinizi görecektir.

    <html>
    <head>
    	<meta charset="utf-8">
    	<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
    </head>
    <body>
    
    <a href="javascript:;" onclick="gonder('d1','d2')">Gönderici</a>
    <div id="response"></div>
    
    <script type="text/javascript">
    
    function gonder(d1, d2){
    	$.ajax({
    		type: "POST",
    		url: "post_adresi.php",
    		data: "d1="+d1+"&d2="+d2,
    		success: function(answer){
    			$("#response").html(answer); 
    		}
    	});
    }
    
    </script>
    </body>
    </html>