Mysql-destroy of backbone + php

Source: Internet
Author: User
I rewrite the destroy () of backbonesync to correspond to php (click the delete button to trigger the delete event), and delete the data in php, but because the url is defined in the collection, when rewriting destroy url, the corresponding operation cannot be performed. please answer! {Code ...} {generation... I rewrite the destroy () of backbone sync to correspond to php (clicking the delete button will trigger the delete event), and delete the data in php, but because the url is defined in the collection, when rewriting destroy url, the corresponding operation cannot be performed. please answer!

//CollectionApp.Users=Backbone.Collection.extend({  model : App.User,  url : function(){    return '/crud2/save.php';  },  initialize : function(){    this.on('add',function(){      console.log(this.length);    });    this.on('remove',function(){      console.log(this.length);    });  }});
  `delete : function(){  //this.model.url='delete.php';  //console.log(this.model.url);  $('#Name').val("");  $('#Phone').val("");  this.model.destroy({    url : 'delete.php',    type : 'POST',    success : function(){      console.log('success');    },    error : function(){      console.log('error');    }  }  ); }`
//delete.php
  username);        $sql = "delete from user where username == '$data->username'";        mysql_query($sql);?>

Reply content:

I rewrite the destroy () of backbone sync to correspond to php (clicking the delete button will trigger the delete event), and delete the data in php, but because the url is defined in the collection, when rewriting destroy url, the corresponding operation cannot be performed. please answer!

//CollectionApp.Users=Backbone.Collection.extend({  model : App.User,  url : function(){    return '/crud2/save.php';  },  initialize : function(){    this.on('add',function(){      console.log(this.length);    });    this.on('remove',function(){      console.log(this.length);    });  }});
  `delete : function(){  //this.model.url='delete.php';  //console.log(this.model.url);  $('#Name').val("");  $('#Phone').val("");  this.model.destroy({    url : 'delete.php',    type : 'POST',    success : function(){      console.log('success');    },    error : function(){      console.log('error');    }  }  ); }`
//delete.php
  username);        $sql = "delete from user where username == '$data->username'";        mysql_query($sql);?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.