tags:

views:

52

answers:

2

Hello everyone,

How do I dynamically retreieve images using any jquery gallery/slideshow plugins?

I have images that I can retrieve like this..

http://localhost/images.aspx?id=1

http://localhost/images.aspx?id=2

I have already made a REST based service to return an array of those links when I pass the fromdate and todate.

After using Jquery to retrieve those links,I want to load the images.

The samples in most of the demos only talk about statically assigning images.

Please show me a sample on loading the images dynamically.

Thanks

A: 

Assuming the REST response will be like this

http://localhost/images.aspx?id=1

Your jquery ajax code should be like this

The code after requesting from REST thru ajax will add the path http://localhost/images.aspx?id=1 to the IMG tag

$.ajax({
  url: 'ajax/test.html',
  success: function(data) {
    $('#imagepic').attr('src',data);
  }
});
Gerard Banasig
but how do I create the image tags dynamically? In this case,I must have a static img tag named imagepic right? but i need to create the tags also dynamically
Josh
I just made a new post to reply to your query http://stackoverflow.com/questions/2174763/retrieving-images-using-jquery-gallery-plugin-dynamically/2175242#2175242
Gerard Banasig
A: 

To also dynamically create the image tag dynamically do this, asumming its inside a div tag

$.ajax({
  url: 'ajax/test.html',
  success: function(data) {
    $('#div1').html("<img src='".data."' id='#imagepic'/>");
  }
});
Gerard Banasig