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 9040835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:05:14+00:00 2026-06-16T10:05:14+00:00

Whilst waiting for ‘real-time’ data from the server, I want to display a gif

  • 0

Whilst waiting for ‘real-time’ data from the server, I want to display a gif image. Otherwise the client sees nothing and doesn’t know about the status of their request. With a gif image such as an ‘egg-timer’ for instance they would at least know that the request has been sent and client is now awaiting a response.

This is how I coded it:

  websocket.onmessage = function(data){
     while (!data){
     $("#display").append('/templates/image.gif');
     }
     CODE THAT IS EXECUTED ON RECEIPT OF data
    }

I’m using websockets for the communication protocol between client and server. But the gif image is not displayed whilst waiting for data from the server.

I’m a newbie to javascript so not sure what id wrong

EDIT

Thanks for the help, your suggestions got the gif image to work.

BUT the image I get is not a gif but what looks like a broken picture icon in (Chrome and nothing in Firefox). This is the code now:

$("#display").append('<img src="/templates/image.gif" />');
websocket.onmessage = function(data){
         CODE THAT IS EXECUTED ON RECEIPT OF data
}

The gif file is ok and in the right directory.

Thanks

  • 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-06-16T10:05:16+00:00Added an answer on June 16, 2026 at 10:05 am

    I think you should be using:

    $("#display").append('<img src="http://www.yourhost.com/templates/image.gif" />');
    

    instead of:

    $("#display").append('/templates/image.gif');
    

    Alternatively you could also create a simple css class as follows:

    .loading {
        display: block;
        width: 16px;
        height: 16px;
        background: transparent url('/templates/image.gif') no-repeat center center;
    }
    

    and then do :

    $("#display").append('<span class="loading"></span>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html page and whilst it's waiting for data from the server
It's a pretty standard setup, WinForms client > Self-serving Business/Data layer > SQL Server
Whilst doing exam revision I am having trouble answering the following question from the
I'm wanting to get an image overflowing a div, whilst not distrupting flow of
Whilst fiddling recently with Ulysses 2.0 - The definitive creative writing package, I was
Whilst a few questions mention using Lua in conjunction with some other language, I
Whilst reading jQuery Cookbook (Oreilly) last night I came across an each function that
Whilst asynchronous IO (non-blocking descriptors with select/poll/epoll/kqueue etc) is not the most documented thing
Whilst working on some generally horrible Javascript code this morning, I came across the
Whilst I'd love to solve this problem in python, I'm stuck in Delphi for

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.