(澳门美高梅在线赌博) 关于backbone+php的destroy问题
澳门美高梅官网
澳门美高梅官网
当前位置 : 澳门美高梅官网 > 澳门美高梅在线赌博

(澳门美高梅在线赌博) 关于backbone+php的destroy问题

我通过重写backbone sync的destroy()来对应到php点击删除按钮会触发delete事件,在php里实现对数据的删除,但是因为collection里定义了url,在重写destroy的url时,无法执行相应操作,求解答!

//Collection
App.Users=Backbone.Collection.extend{
  model : App.User,
  url : function{
    return /crud2/save.php;
  },
  initialize : function{
    this.onadd,function{
      console.logthis.length;
    };
    this.onremove,function{
      console.logthis.length;
    };
  }
};
  `delete : function{
  //this.model.url=delete.php;
  //console.logthis.model.url;
  $#Name.val"";
  $#Phone.val"";
  this.model.destroy{
    url : delete.php,
    type : POST,
    success : function{
      console.logsuccess;
    },
    error : function{
      console.logerror;
    }
  }
  ; 
}`

//delete.php
<?php
    date_default_timezone_setprc;
    error_reportingE_ALL ^ E_DEPRECATED;
    header"Content-type : application/json; charset = utf-8";  
    $connection=mysql_connect"localhost","root","123456";
    if!$connection{
        dieconnect failed!;
    }else{
        mysql_select_db"backbone";
        mysql_query"set names utf-8";
        $data = json_decodefile_get_contents"php://input";
        //echo $data;
        file_put_contents"data.txt", $data->username;
        $sql = "delete from user where username == $data->username";
        mysql_query$sql;
?>

广告位

澳门美高梅官网