CakePHP Ajax delete -


I am trying to delete cakepap data by AJAX. Here I click the PostLink button with the simple HTML button such as

  & lt; Button class = "del" id = & lt ;? Php echo $ user ['user'] ['id']; ? & Gt; & Gt; Remove & lt; / Delete & gt; I am able to get a user ID here by using the bellow code  
  $ ('document').  

Click Ready (function () {$ ('dell') (function () {var x = $ (this) .attr ("id"); alert (x);});});

I have successfully acquired the user's ID. I am now trying to send it to the removal action of the user controller. So I have coded

  $ ("document") ready (click the function () {$ ('dell') (function () {var x = $ (this). Attr ("id"); alert (x); jQuery.get ("function (data, state) {jQuery (" ###########============ ================================================== ================================== "Success"). Load ("success.ctp");});} );});  

Now I have tried the deleted action in the controller

  Delete public function ($ id = NUll) {$ id = $ _ GET [' Id ']; $ This- & gt; User- & gt; Id = $ id; If ($ this-> User-> Delete ()) {$ this-> Session-> Set Flash (__ ('User has been deleted.')); } $ This- & gt; Redirect (Array ('Action' =>); Return; }  

Here it is not working. How can I define this in the controller?

If you use filters before,

  function Before Filters () {// set here which page should be accessible for different users $ adminPages = array ('delete'); $ This- & gt; Auth-> Allow ($ adminPages); ......}  

Allow it to execute with the help of Aeth.

If this is working well then check that the AJAX string is justified or not. Check by using Manual Deletion like abc.com/users/delete/id , just copy paste string in jQuery.get () . Is it properly removed ??

If all works, try the following: :)

  Deleting a public function ($ id = NUll) {$ id = $ _ Received ['id']; $ This- & gt; User- & gt; Id = $ id; If ($ this-> User-> Delete ()) {$ this-> Session-> Set Flash (__ ('User has been deleted.')); } $ This- & gt; Redirect (Array ('Action' =>); Return; }  

and Ajax:

  jQuery.get ("& lt ;? php echo $ this-> webroot. $-> this-> Paramet ["(" #success "). Load (" success.ctp ")" /. ";});  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -