jeudi 14 janvier 2016

delete using javascript in Laravel

i want to delete records with alert messages using javscript on my laravel view without refreshing the page.

my current code

 var dell = "Are you sure you want to delete ?";
var del_url = "{{url('destroy-shift')}}/" + json_obj[i].id;
                                                output +=

                                                        "<td></td>" +
                                                        "<td></td>" +
                                                        "<td>" + json_obj[i].START + "</td>" +
                                                        "<td>" + json_obj[i].END + "</td>" +
                                                        "<td>" + res + "</td>" +
                                                        "<td>" + json_obj[i].RUN + "</td>" +
                                                        "<td><a data-toggle='modal'  data-target='#myModal3"+xx+"' href='" + url + "' ><span class='glyphicon glyphicon-pencil '></span></a>" +
                                                        "<div class='modal fade' id='myModal3"+xx+"' role='dialog'>" +
                                                        "<div class='modal-dialog'>" +
                                                        "<div class='modal-content'><div class='modal-body'></div>" +
                                                        "</div>" +
                                                        "</div>" +
                                                        "</div>" +
                                                        "<a href='" + del_url + "' ><button type='submit' id='delete-btn' onclick='return confirm('" + dell + "')'><span class='glyphicon glyphicon-trash'></span></button></a></td>";


                                            output += "</tr>";

but still page is refreshing and im not getting the confirmation message too. plse advice



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire