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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:58:38+00:00 2026-06-10T05:58:38+00:00

How to refill the image src with the value from imageArray[0]? $.getJSON(http://xxxx,function(data) { var

  • 0

How to refill the image src with the value from imageArray[0]?

$.getJSON("http://xxxx",function(data) {
    var imageArray=[];
    imageArray=data.images;
    alert(imageArray[0]);
    $('#loader').empty();
    var imageOne= '<img style="display:none;" src="imageArray[0]" id="1" wdith="100" />';
    $("#ajax_content").html(imageOne);
    $('img#1').fadeIn();
});

I want to refill the imageArray[0] as below

var imageOne= '<img style="display:none;" src="http://i2.cdn.turner.com/cnn/dam/assets/120824111207-storm-isaac-t1-main.jpg" id="1" wdith="100" />';

@thanks undefined

I want to have all of them in an array and show only the first image. Later i will work on having previous/next button to move on to next image. Can you currect the following to work?

for (var i=0;i<imageArray.length;i++){
                        imageOne[i]='<img style="display:none;" src="'+imageArray[i]+'" id="i" wdith="100" />;';
                    }
                    $("#ajax_content").html(imageOne);
                    $('img#1').fadeIn();
  • 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-10T05:58:40+00:00Added an answer on June 10, 2026 at 5:58 am
    $.getJSON("http://xxxx", function(data){
        var imageArray=[];
        imageArray = data.images;
        $('#loader').empty();
        for (var i = 0; i < imageArray.length; i++) {
            var img = '<img style="display:none;" src="'+imageArray[i]+'" id=img"'+i+'" wdith="100" />';        
            $("#ajax_content").append(img);
            $('#img'+i).fadeIn();
        }
    });
    

    Update:

    var img = [];
    for (var i = 0; i < imageArray.length; i++) {
        img[i] = '<img style="display:none;" src="'+imageArray[i]+'" id="'+(i+1)+'" width="100"/>';
    }
    $("#ajax_content").html(img[0]);
    $('img#1').fadeIn();
    

    Note that if the doctype of your page is not HTML5, IDs must begin with a letter and also note that there is a typo in your string literal wdith should be width.

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

Sidebar

Related Questions

I have this code just to send data from already loaded jqGrid: jQuery(#bedata).click(function(){ //Function
I want to re-populate (i.e refill) values posted from a select form field after
i want to refill the image when i click on the capthca . how
Hi I am developing an android in which I am loading data from database
I am using GWT RPC & Hibernate to insert and retrieve data from MySQL
I do something like this: $(#id1).html(data); I refill a div with html but when
I have a simple table for reference page: id name description image In reference.php,
So, I've run into a problem with PHP's rawurlencode function. All text fields in
I have that code: jQuery(document).ready(function () { // binds form submission and fields to
In my viewmodel, I have a list of items I fetch from the database

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.