hobbiton73 Posted May 11, 2012 Share Posted May 11, 2012 I wonder whether someone may be able to help me please. I've put together this http://www.mapmyfinds.co.uk/development/deletetest.php page which allows users to view a gallery of their uploaded images. Upon initial upload, the physical images are saved in the following file structure: UploadedFiles/userid/locationid/image and the details of the image i.e. description etc are saved in an xml file called 'files.xml' which is stored in the same directory as the physical images. I'm now working on allowing the user to be able to delete these images. By way of a deletion icon under each image, I've, admitedly with some 1st class help from scootstah on this forum, put together the following which successfully deletes the physical image. 'Onclick Event' <script type="text/javascript"> Galleria.ready(function() { this.$('thumblink').click(); $(".galleria-image").append( "<span class='btn-delete ui-icon ui-icon-trash'></span>"); $(".btn-delete").live("click", function(){ var img = $(this).closest(".galleria-image").find("img"); // send the AJAX request $.ajax({ url : 'delete.php', type : 'post', data : { image : img.attr('src') }, success : function(){ alert('Deleting image... '); img.parent().fadeOut('slow'); } }); return false; }); }); </script> delete.php <?php if (!empty($_POST)) { $image = $_POST['image']; if (file_exists($image)) { unlink($image); } } ?> The problem I'm having, is deleting the matching node in my xml file, an extract of which can be found below: <?xml version="1.0" encoding="utf-8" ?> - <files> <file name="stag.jpg" source="stag.jpg" size="21341" originalname="stag.jpg" description="No description provided" userid="1" locationid="1" /> </files> I've done quite a bit of research and found that the jQuery had a command call 'jQuery.remove'. Using a brief tutorial I found, I added the folowing to the end of my 'Onclick event' script. var doc = $(files.xml); doc.find('file_name:src').remove(); Unfortunately, although I receive no error message, the row in my XML is not deleted, and I'm not really sure why. I just wondered whether someone could have a look at this and let me know where I've gone wrong. Many thanks and kind regards Quote Link to comment https://forums.phpfreaks.com/topic/262406-delete-xml-node-with-jqueryremove/ Share on other sites More sharing options...
trq Posted May 12, 2012 Share Posted May 12, 2012 jQuery operates on the dom, not the actual file. Quote Link to comment https://forums.phpfreaks.com/topic/262406-delete-xml-node-with-jqueryremove/#findComment-1344909 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.