egyamado
egyamado

Reputation: 1121

call URL inside get() method in jQuery

Ok. I have the following jQuery code

jQuery(function(){
jQuery.get('/GalleryPage.aspx?gallery=1234', {}, function(data) { 
galleryXML = data;
renderGallery(pageIndex);
}, "xml");          
});

As you can see, I have 1 URL ('/GalleryPage.aspx?gallery=147') which I display it in “GalleryView.html”. Now I want to show another URL/ID in the same page like so ('/GalleryPage.aspx?gallery=258').

Can I add the url beside each other like so

jQuery.get('/GalleryPage.aspx?gallery=1234', 
'/GalleryPage.aspx?gallery=1234', {}, function(data) { 

How can I display 2 URL in the same get() function????

Thanks.

Upvotes: 0

Views: 3992

Answers (2)

egyamado
egyamado

Reputation: 1121

yes JBristow, you got my Q right :)

Ok may be i forget to add the following code in my Q.

jQuery('#placeholderGallery').empty();
jQuery(jQuery(html)).appendTo('#placeholderGallery');

Where (#placeholderGallery) contains the media gallery which i want to repeat adding it when ever i have new one.

so what i did is, comment the first line [jQuery('#placeholderGallery').empty();] , and then repeat my first entry as following:

    jQuery(function(){
        jQuery.get('GalleryPage.aspx?gallery=369', {}, function(data) { 
            galleryXML = data;
            renderGallery(pageIndex);
        }, "xml");          
    }); 
    jQuery(function(){
        jQuery.get('GalleryPage.aspx?gallery=365', {}, function(data) { 
            galleryXML = data;
            renderGallery(pageIndex);
        }, "xml");          
    });

Hope this helps, and thanks guys for your help :)

Upvotes: 0

Jon Bristow
Jon Bristow

Reputation: 1725

No, you cannot put two url's in jquery's get.

You could always nest the two gets... I'm assuming here that you want to render two pages of gallery on one page...

var galleryTemp;
jQuery(function(){
  jQuery.get('/GalleryPage.aspx?gallery=1234', {}, function(data) { 
    galleryTemp = data;
    jQuery.get('/GalleryPage.aspx?gallery=2345', {}, function(data) { 
      galleryXML = data;
      $(galleryXML).prepend($(galleryTemp).children());
      renderGallery(pageIndex);
  }, "xml");              
});

Unfortunately, I don't have a good solution for you off the top of my head for loading N pages...

Upvotes: 1

Related Questions