Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6358909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:26:56+00:00 2026-05-24T23:26:56+00:00

The following jQuery’s goal is to load images from a server, and then control

  • 0

The following jQuery’s goal is to load images from a server, and then control the number of images per page, as well as navigate through the pages. It’s not functioning.
I’m hoping someone can shed some light on whats wrong with it.

I’ve gotten the pagination to work, but then the combo box page selector doesn’t work. I’ve gotten the combo box selector to work, but then the images and pagination won’t load. Right now only the combo box is showing, and although it looks as if it works, no images are visible, so it’s hard to tell.

The HTML:

<div id="loading"></div>
<div id="gallery_container">
    <ul class="new_arrivals_gallery"></ul>
    <div class="pagination"></div>
</div>
<form>
    <label>Images Number:</label>
    <select id="imgNum" name="imgNum">
        <option value="12">12</option>
        <option value="16">16</option>
        <option value="20">20</option>      
    </select>
</form>

The jQuery:

slideshow = { page: 0, imgs: '' };

function loadData(){
    loading_show();
    gallery_hide();                    
    $.ajax
    ({
        type: "GET",
        url: "new_arrivals_data.php",
        data: slideshow,
        success: function(msg) {
            gallery_show();
            $("#gallery_container").html(msg);
            console.log(msg);
        },
        error: function(jqXHR, textStatus, errorThrown) {
            // Tell the human that something broke.
        },
        complete: function() {
            // This is always called regardless of success or failure.
            loading_hide();
        }
    });
}
loadData(1);  // For first time page load default results
$('#gallery_container .pagination li.active').live('click',function(){
    slideshow.page = $('#gallery_container .pagination li.active').attr('p');
    loadData();
});           
$('#go_btn').live('click',function(){
    slideshow.page = parseInt($('.goto').val());
    var no_of_pages = parseInt($('.total').attr('a'));
    if(page != 0 && page <= no_of_pages){
        loadData();
    }else{
        alert('Enter a PAGE between 1 and '+no_of_pages);
        $('.goto').val("").focus();
        return false;
    }
});

//Bind the onChange event to Fetch images on combox selection
$("#imgNum").change(function(){
    console.log('hi');
    slideshow.imgs = $('imgNum').val();
    loadData();
})
//You should store the current selected option in a cookie
//For the sake of the example i'll set the default permanently to 12
var imgNum_selected = 12;

//set the initial selected option and trigger the event
$("#imgNum [value='"+imgNum_selected+"']")
    .prop("selected","selected");
    $("#imgNum").change();

The Original Code

The HTML:

<div id="loading"></div>
<div id="gallery_container">
    <ul class="new_arrivals_gallery"></ul>
    <div class="pagination"></div>    
</div>
<form>
    <label>Images Number:</label>
    <select id="imgNum" name="imgNum">
        <option value="12">12</option>
        <option value="16">16</option>
        <option value="20">20</option>      
    </select>
</form>

The jQuery Ajax:

function loading_show(){
    $('#loading').html("<img src='loading.gif'/>").fadeIn('fast');
}
function loading_hide(){
    $('#loading').fadeOut('fast');
}                
function gallery_show(){
    $('#gallery_container').fadeIn('slow');
}
function gallery_hide(){
    $('#gallery_container').fadeOut(10);
}

function loadData(page){
    loading_show();
    gallery_hide();                    
    $.ajax
    ({
        type: "GET",
        url: "new_arrivals_data.php",
        data: {page:page, imgs: value},
        success: function(msg)
        {
            $("#gallery_container").ajaxComplete(function(event, request, settings)
            {
                gallery_show();
                loading_hide();
                $("#gallery_container").html(msg);
            });
        }
    });
}
loadData(1);  // For first time page load default results
$('#gallery_container .pagination li.active').live('click',function(){
    var page = $(this).attr('p');
    loadData(page);
});           
$('#go_btn').live('click',function(){
    var page = parseInt($('.goto').val());
    var no_of_pages = parseInt($('.total').attr('a'));
    if(page != 0 && page <= no_of_pages){
        loadData(page);
    }else{
        alert('Enter a PAGE between 1 and '+no_of_pages);
        $('.goto').val("").focus();
        return false;
    }
});

//Bind the onChange event to Fetch images on combox selection
$("#imgNum").change(function(){
    //The combo box
    var sel = $(this);
    //Selected value
    var value = sel.val();
    loadData(page);
})
//You should store the current selected option in a cookie
//For the sake of the example i'll set the default permanently to 12
var imgNum_selected = 12;

//set the initial selected option and trigger the event
$("#imgNum [value='"+imgNum_selected+"']")
    .prop("selected","selected")
    .change();

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:26:57+00:00Added an answer on May 24, 2026 at 11:26 pm

    Managed to get this working. Specifically the jQuery as the HTML was fine.

    I am thinking there are still some general clean ups I could do to this. If you have any advice, please let me know!

    Here is the functioning code:

    (function() {
        var page;
    
        function loading_show(){
            $('#loading').html("<img src='loading.gif'/>").fadeIn('fast');
        }
        function loading_hide(){
            $('#loading').fadeOut('fast');
        }                
        function gallery_show(){
            $('#gallery_container').fadeIn('slow');
        }
        function gallery_hide(){
            $('#gallery_container').fadeOut(10);
        }
    
    
        function loadData(page, imgs){
            loading_show();
            gallery_hide();                    
            $.ajax
            ({
                type: "GET",
                url: "new_arrivals_data.php",
                data: {page:page, imgs:imgs},
                success: function(msg) {
                    $("#gallery_container").html(msg);
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    // Tell the human that something broke.
                },
                complete: function() {
                    // This is always called regardless of success or failure.
                    gallery_show();
                    loading_hide();
                }
            });
        }
        loadData(1);  // For first time page load default results
        $('#gallery_container .pagination li.active').live('click',function(){
            var imgs = $("#imgNum").val();
            var page = $(this).attr('p');
            loadData(page, imgs);
        });           
        $('#go_btn').live('click',function(){
            var imgs = $("#imgNum").val();
            var page = parseInt($('.goto').val());
            var no_of_pages = parseInt($('.total').attr('a'));
            if(page != 0 && page <= no_of_pages){
                loadData(page, imgs);
            }else{
                alert('Enter a PAGE between 1 and '+no_of_pages);
                $('.goto').val("").focus();
                return false;
            }
        });
    
        //Bind the onChange event to Fetch images on combox selection
        $("#imgNum").change(function(){
            //The combo box
            var sel = $(this);
            //Selected images value
            var imgs = sel.val();
            var page = $('#cur_page').attr('cur_page');
            //Feth the images
            loadData(page, imgs);
        })
        //You should store the current selected option in a cookie
        //For the sake of the example i'll set the default permanently to 12
        var imgNum_selected = 16;
    
        //set the initial selected option and trigger the event
        $("#imgNum [value='"+imgNum_selected+"']").prop("selected","selected").change();
    
    }());
    

    Thanks for all the help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am calling the following jQuery code on page load to test the concept
I have the following JQuery code that processes a GET request upon page load:
I have the following jQuery that does find the ASP.NET server control (tested by
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have the following jquery code: $(document).ready(function() { $(body[class*=page-calendar-practices] #content-header h1#title).after(<div id='athletics_practice-schedule'><div id='inner-title'><a href='www.example.com'
The following jQuery Javascript code is included on an otherwise empty page. var element;
The following jQuery snippet fails if a page also includes mootools-core.js. The foo2 object
The following jquery I am using in my jsp page for adding an autocomplete
I have the following jQuery code (take from another question somewhere here): $(document).ready(function(){ $(#profile_dropdown).mouseenter(function(){
The following jQuery is not working as expected. I'm simply trying to fire an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.