I am still learning Laravel 4 so I have a resourceful controller tasks and I am having a problem implementing my jquery.
My delete works fine without jquery so i think that I am not providing the proper url
I have found one problem I don't know how to pass my id to jquery,it apears that is not assigned.

$('#delete').on("click",function(event) {
    var answer = confirm('Are you sure you want to delete this?');
if (answer===true)
    url: 'tasks/'+id,
    type: 'POSt',
    success: function(result) {
        // Do something with the result

  return false;

My view with the delete part

{{ Form::open(array('method'=>'DELETE', 'route'=>array('tasks.destroy', $t->id))) }}
                {{Form::submit('Delete',array('class'=>'btn btn-danger','id'=>'delete'))}}

Thank you for your help

Edited by dany12: more info

3 Years
Discussion Span
Last Post by cereal

That is my problem I don't know how to get it because I am using it directly in the route.
So I can't do this .


This is what it should go to my

url:route'=>array('tasks.destroy', $t->id

But i don't know how to make it work


I know that I can't mix php with jquery.I want to find a way to get the action form the delete form to my jquery.
For an input I would do it like this.


I will dig deeper to see if I can find what i am looking for

Thanks for the reply.


Ok I found out that I can use the attribute method from jquery.

Edited by dany12


Now I have the delete working but i get 500 error form the server

var del = $('form').attr('action');
data={_method: 'delete' };

    url:  del,
    type: 'POSt',
    success: function(result) {
        console.log('You have deleted me.');

The error

DELETE http://ltask.dev/tasks/7 500 (Internal Server Error)    jquery-1.10.2.min.js:6
send jquery-1.10.2.min.js:6
x.extend.ajax jquery-1.10.2.min.js:6
(anonymous function) main.js:17
x.event.dispatch jquery-1.10.2.min.js:5
v.handle jquery-1.10.2.min.js:5

Ok it is working now I had a problem with my cache form the browser Thank you everyone.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.