events - Jquery is not showing results -
i need make jquery alert "are sure want delete" when user click on delete i've been trying lot didnt find solution
this deletemovie.php
<?php require('../system/initialize.php'); //load connection file ?> <html><script src="../js/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $(".delete").click(function () { if ( !confirm('are sure want delete?') ) { return false; } else { $.ajax({ url: "deletemovie.php", data: {movie_id}, type: 'get', async: false, success: function(result) { if( result.success ) { alert("you have deleted"); } } }) } }) ) </script> </html> <?php $movie_id=$_get['movie_id']; $insert_user=mysql_query("delete `movie` `movie_id` ={$movie_id}"); if($insert_user) { echo "deleted";} else { echo "error in registration".mysql_error(); } ?>
of course, in list page did:
echo "<a class='delete' href='deletemovie.php?movie_id={$movie_id}'>". delete .'</a><br/></td>';
you missing semicolons , brackets. , there should correction in data parameter of ajax call. use following code , work you
$(function () { $(".delete").click(function () { if (!confirm('are sure want delete?')) { return false; } else { $.ajax({ url: "deletemovie.php", data: { 'movie_id': <id of movie> }, type: 'get', async: false, success: function (result) { if (result.success) { alert("you have deleted"); } } }); } }); });
note: have replace <id of movie>
actual id of movie want delete
Comments
Post a Comment