Maybe I'm going about thewrong way, but this is what I'm trying to achieve:
I have a page with thumbnails. Underneath each thumbnail there's a 'delete' link: <a class="delete" href="#" onclick="javascript:delete_photo('.$img- >photo_id.')">Delete</a> On click I would like to fire a confirmation message. Upon confirmation the image should be deleted for which I have made a function that's in 'main.js': function delete_photo (photo_id) { confirm('Are you sure you want to delete this photo?'); $.post("http://www.domain.com/delphoto/"+ photo_id); $("#"+ photo_id).fadeOut(500); return false; }; The post works, the photo gets deleted, but on cancel the deletion is also executed. I can see that how I've done it now is incorrect because yes, the $post is right behind the confirmation so it's logical it's being executed. But how do you do this the right way?? Thanks in advance!!