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

  • SEARCH
  • Home
  • 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 5946423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:49:16+00:00 2026-05-22T16:49:16+00:00

$(document).ready(function(){ $(#submit).click(function() { var startDate = $(#startdate).val(); var endDate = $(#enddate).val(); var selected =

  • 0
$(document).ready(function(){
    $("#submit").click(function() {  

        var startDate = $("#startdate").val();
        var endDate = $("#enddate").val();
        var selected = $("#selected").val();

        $.ajax({
            type: "POST",
            url: "/json/chart",
            data: {
                selected:selected, 
                startDate:startDate, 
                endDate:endDate
            },
            success: function(data) {  

                $("#pkgLineDiv").empty().html("");                  

                $.each(data, function(index) {                         
                    $('#pkgLineDiv').prepend('<img id="'+ index+'" src="/public/images/ajax-loader.gif" /><br />');
                    $('#'+index).attr('src', 'chart/'+ data[index].pkgLineId +'/'+ data[index].wrapSpecId +'/'+ data[index].startDate +'/'+ data[index].endDate);                   
                });                           
            }

        });
        return false;           
    });
}); 

This is my code. I’m doing an ajax submit and getting some json data back. I’m then passing this data into a chart url. This chart url is a function that generates an image in the back end. The problem is this could be a long process. A simple ajax loading image doesn’t work because the ajax call is quick (gets a quick json array). It’s what happens after the ajax call that take a while. What I’m trying to do is get an image to show where the image will be. I can’t have a place holder because I don’t know how many images are going to be created.

This code will work in IE 8. The animation will not play but at least the image shows up where the final image will be. In Chrome and Firefox (my main testing environments) the image will not show at all. Is there something I am missing here? Thanks.

EDIT

:

      $("#pkgLineDiv").empty().html("");  //Empty all contents of the div to push new chart images       
                $.blockUI();
                $.each(data, function(index) {    

                    var chartUrl = 'chart/'+ data[index].pkgLineId +'/'+ data[index].wrapSpecId +'/'+ data[index].startDate +'/'+ data[index].endDate;  //Build chart URL
                    $('#pkgLineDiv').prepend(''+ data[index].description +'<div><img id="'+ index +'" src="/public/images/ajax-loader4.gif" /></div');


                    $.get(chartUrl, function() {                           
                        $('#'+index).attr('src', chartUrl);  

                        if (index == data.length - 1) {
                            $.unblockUI();   
                        }                       
                    });      
                });
  • 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-22T16:49:16+00:00Added an answer on May 22, 2026 at 4:49 pm

    I’ve not done this before so I can’t say for sure, but perhaps try to initially set the img srcs to the loader.gif then make ajax requests to each of the chart/’+ data… (i.e. the chart images) then on success set the src to the chart image. If the chart image’s headers indicate the client can cache that URL, then I believe it should work the way you want.

    I believe the issue is how different browsers handle the changing of img src. If you don’t change the src until you know the image has been rendered by the server and cached by the client, you should be good.

    Something like this:

    $(document).ready(function(){
    
        $("#submit").click(function() {  
    
            var startDate = $("#startdate").val();
            var endDate = $("#enddate").val();
            var selected = $("#selected").val();
    
            $.ajax({
                type: "POST",
                url: "/json/chart",
                data: {
                    selected:selected, 
                    startDate:startDate, 
                    endDate:endDate
                },
                success: function(data) {  
    
                    $("#pkgLineDiv").empty().html("");                  
    
                    $.each(data, function(index) {                         
                        $('#pkgLineDiv').prepend('<img id="'+ index+'" src="/public/images/ajax-loader.gif" /><br />');
    
                        var chartUrl = 'chart/'+ data[index].pkgLineId +'/'+ data[index].wrapSpecId +'/'+ data[index].startDate +'/'+ data[index].endDate;
    
                        $.get(chartUrl, function(data){ $('#'+index).attr('src', chartUrl); }); // get
    
    
                    }); // each                           
                } // success
    
            }); // ajax
            return false;           
        }); // click
    });  // ready
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(document).ready(function(){ $(.submit).click(function() { var emailVal = $(.email).val() $.ajax({ type: 'POST', url: 'settings/update', data: {
and actually i convert the url with javascript <script type=text/javascript> $(document).ready(function() { $('.search-form').submit(function() {
$(document).ready(function() { $('#content').html(''); $.ajax({ url:'data.json', dataType: json, success: function(data) { $('#content').append('<p>'+data.rank+'</p>'); } });}); In
$(document).ready(function() { $('#username').focus(function() { $(this).val(''); }) $('#username').blur(function() { var l = $(this).val.length; if (l
$(document).ready(function() { //Check City Value var city_value = parseInt($(#city).val()); if( city_value == 0) {
$(document).ready(function() { $('form#search').bind(submit, function(e){ e.preventDefault(); $('#content').html(''); // Define the callback function function getGeo(jsonData) {
I'm using jquery to submit my form (with id #myForm here) as follows: $(document).ready(function()
$(document).ready(function() { function countChecked() { var n = $(input:checked).length; $(div).text(n + (n <= 1
$(document).ready(function(){ $(a[href*='http://']:not([href*='+location.hostname+'])).attr(target,_blank); $(a[target!='_blank'][target!='_top']).click(function(){ $(#actualcontent).load($(this).attr(href)); window.location.hash=$(this).attr(href); return false; }); }); So I have this code
<script type=text/javascript> $(document).ready(function($){ $.supersized({ //Background image slides : [ { image : 'images/pendulumWeb.jpg' }

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.