Search code examples
jqueryweb-serviceshtmldatasetphotoswipe

Appending Dataset Results to a div with specific requirements


I am currently trying to incorporate 'PhotoSwipe' for jQuery into my application with images that are pulled from a database via a POST to my webservice, and a little serialization magic.

I am still kinda new to jQuery, but I've gotten pretty far considering.

I still have yet to figure out how to use code properly on this site, so here's a pastebin of the code in question:

http://pastebin.com/avSXDDgK

Basically what it does is comb through my dataset, find anything wrapped in an image tag and pull it into a variable. Which it does.

What I have to do, is combine that information, to ultimately form something resembling this:

<a href="C:/images/full/001.jpg" rel="external"><img src="C:/images/thumb/001.jpg" alt="Image 001" /></a>

So what I need is for someone to show me or point me in the right direction towards a resolution.

Currently all the alerts work for me, however nothing actually happens to the div.

Thanks for any help!

Edit: Here is an example of the XML in which my image urls are being pulled from

http://pastebin.com/nnvdKgqV

...and here is a link to PhotoSwipe, they say to use rel="external" within the tags


Solution

  • $(data).find('Table').each(function(){ var tableData1 = $(this); // 'this', in your example, refers to the Table data

    var image = $(tableData1).find('image').text();
    var imagepath = 'C:/inetpub/wwwroot/' + image + '" </img>' ;
    
    var i = '<img src="' +imagepath+ '</img>' ;
    $('#gallery2').append(i)
    alert(imagepath);
    
    
    });
    
    
    });
    

    Thanks @Crab via #jQuery IRC