开发者

Send var-value using jquery post, mysql

I use ajax/json to fetch a random row from a mysql-server using a php. The different data from the random row I get is then stored in vars.

          $.ajax({                                      
          url: 'api.php',                  
          data: "",                 
          dataType: 'json',         
          success: function(data)         
          {
          var id = data[0];
        .....

I then want to use the field ID as an identifyer to update a field in that specific row in the mysql-database using a update.php.

     $sql = "UPDATE table SET field1 = field1 +1 WHERE id = '???'";

Now, I'm new to using jquery-post, so can somebody help me to pass on the data (the ID-number) AND use it correctly in the update.php?

  <script>
  $(document).jkey('开发者_运维知识库a',function() {
         $.post("update.php");
        $('.id').html(data);
    });
</script>


$.post("test.php", { name: "John", time: "2pm" } );

as you can see in the examples

http://api.jquery.com/jQuery.post/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜