• 12-07-2022, 11:51:05
    #1
    Merhabalar.
    Butona tıkladığım zaman ajax ile arka plandan güncelle .php ye gidip orda güncelleme yapması lazım.
    herhangibir değer post etmicem. bütün işlemi arka plandan guncelle.php yapıcak.
    guncelle .php de hit diye bir değerim var. id değerim ile birlikte "UPDATE posts SET hit = hit + 1 WHERE id = 1" şeklinde sorgu içinde veriyorum. ek bir veri yollamıyorum. sadece tetikleyici lazım.
    Nasıl Yapabilirim?
  • 12-07-2022, 12:00:12
    #2
    $.ajax({
    url:"", //Dosya yolu
    type:"POST",
    data:, //Göndereceğin data
    success:function(){
    //yapmasını istediğin işlem
    }
    });
    bu işine yarar
  • 12-07-2022, 12:01:16
    #3
    İmzama bakip oradaki form ve scripti alın
    Arka plana .php dosyası koyun
    Get ile veri gönderiyor.
  • 12-07-2022, 12:03:47
    #4
    byroot adlı üyeden alıntı: mesajı görüntüle
    $.ajax({
    url:"", //Dosya yolu
    type:"POST",
    data:, //Göndereceğin data
    success:function(){
    //yapmasını istediğin işlem
    }
    });
    bu işine yarar
    Teşekkürler fakat bir sorum var.
    Sadece update.php ye gitmesini ve işlemimi çalıştırmasını istiorum. Nasıl yapabilirim.
  • 12-07-2022, 12:04:47
    #5
    iltu33 adlı üyeden alıntı: mesajı görüntüle
    Teşekkürler fakat bir sorum var.
    Sadece update.php ye gitmesini ve işlemimi çalıştırmasını istiorum. Nasıl yapabilirim.
    dosya yolunda onu belirt
  • 12-07-2022, 12:07:58
    #6
    byroot adlı üyeden alıntı: mesajı görüntüle
    dosya yolunda onu belirt
    Özür dilerim yazılımda yeniyim. sorularım saçma gelebilir ama hala class ı update olan butona tıklayınca şu dosyaya git çalıştır nasıl derim ?
    :/
  • 12-07-2022, 12:11:14
    #7
    function update(){
     $.ajax({
            url:"", //Dosya yolu 
             type:"POST",
              data:, //Göndereceğin data
              success:function(){
                   //yapmasını istediğin işlem
              }
    });
    }
    <input type='submit' value='update' onSubmit="update()" />
  • 12-07-2022, 12:23:20
    #8
    byroot adlı üyeden alıntı: mesajı görüntüle
    function update(){
     $.ajax({
            url:"", //Dosya yolu 
             type:"POST",
              data:, //Göndereceğin data
              success:function(){
                   //yapmasını istediğin işlem
              }
    });
    }
    <input type='submit' value='update' onSubmit="update()" />
    Teşekkürler. Fakat sanırım bir yerde yanlışlık yapıyorum. Yardımcı olabilirsen sevinirim.

    index.php
    <input type='submit' value='update' onSubmit="update()" />
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0w wj1yYfoRSJoZ+n" crossorigin="anonymous"></script>

    <script>
    function update(){
    $.ajax({
    url:"update.php", //Dosya yolu
    type:"POST",
    data:, //Göndereceğin data
    success:function(){
    //yapmasını istediğin işlem
    }
    });
    }
    </script>

    update.php
    <?php

    require 'mysql.php';

    $id = 1;
    $sorgu = $db->prepare("UPDATE tablom SET hit = hit +1 WHERE id='".$id ."' ");
    $sorgu->execute(array($id));
    ?>
  • 12-07-2022, 23:15:35
    #9
    fatbotter.com
    update.php

    require 'mysql.php';
    if (isset($_POST['process'])) {
      $process = $_POST['process'];
      if ($process = 'update') {
        $id = 1;
        $sorgu = $db->prepare("UPDATE tablom SET hit = hit +1 WHERE id='".$id ."' ");
        $sorgu->execute(array($id));
      }
      if ($process = 'delete') {
        //other processes
      }
      if ($process = 'add') {
        //other processes
      }
    }
    index.php

    <button type="button" id="up" >Update</button>
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0w wj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    
    <script>
    $(document).ready(function(){
      $("#test").click(function(){
        var process = "update";
        $.ajax({
            type:"POST",
            url:"update.php",
            data:{process: process},
            success: function(data){
            }
        });
      });
    </script>