dongri1989 2013-09-23 13:09
浏览 34
已采纳

使用带有php和jquery的$ .post

Ok, Im trying to make a draggable CMS system, now Im stuck on the next problem.

When Im done dragging my 'div' I want to save my new left and top (x and y) variables in my MySQL database using PhP.

I get my left and top variables by the next line of codes:

$(function() {
    $( "#3" ).draggable({ 
        stop: function () {
            $.post("upload.php", {
                left: this.getBoundingClientRect().left,
                top: this.getBoundingClientRect().top
            })
        }, 
        containment: "#containment-wrapper", 
        scroll: false 
    });

my upload.php is:

<?
    mysql_query("UPDATE nvt SET left='". $_POST['left'] ."'")or die(mysql_error());
    mysql_query("UPDATE nvt SET top='". $_POST['top'] ."'")or die(mysql_error());
    header("Location: inlogged");
?>

When I'm done dragging my div there is just no reaction?

  • 写回答

1条回答 默认 最新

  • dongzhong5573 2013-09-23 13:18
    关注

    I think you are missing }); at the end. The code should be :

    $(function() {
     $( "#3" ).draggable({ 
        stop: function ( event, ui ) {
            $.post("upload.php", {
                left: parseInt( ui.offset.left ),
                top: parseInt( ui.offset.top )
            })
        }, 
        containment: "#containment-wrapper", 
        scroll: false 
       });
    }); //see the change
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。