Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. I have problem importing images of Json File on HTML Table

I have problem importing images of Json File on HTML Table

Scheduled Pinned Locked Moved JavaScript
jsonhtmlsharepointdata-structurescollaboration
2 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_15901519
    wrote on last edited by
    #1

    Hello, I successfully loaded the json responses into an HTML table. However, I am having a problem displaying the images of the json variables. I could only display the links. Here is the output:

    Home Team Match Date Away Team
    https://media-3.api-sports.io/football/teams/2939.png 2023-01-22T20:30:00+03:00 https://media-3.api-sports.io/football/teams/2934.png
    https://media-3.api-sports.io/football/teams/2938.png 2023-01-26T21:00:00+03:00 https://media-3.api-sports.io/football/teams/2939.png
    https://media.api-sports.io/football/teams/2931.png 2023-02-03T17:00:00+03:00 https://media.api-sports.io/football/teams/2939.png
    https://media.api-sports.io/football/teams/2937.png 2023-02-09T19:30:00+03:00 https://media-3.api-sports.io/football/teams/2939.png
    https://media-3.api-sports.io/football/teams/2939.png 2023-02-17T17:00:00+03:00 https://media-3.api-sports.io/football/teams/2936.png

    Here is a sample of the json file:

    array (
    'api' =>
    array (
    'results' => 10,
    'fixtures' =>
    array (
    0 =>
    array (
    'fixture_id' => 932017,
    'league_id' => 4633,
    'league' =>
    array (
    'name' => 'Pro League',
    'country' => 'Saudi-Arabia',
    'logo' => 'https://media-3.api-sports.io/football/leagues/307.png',
    'flag' => 'https://media-3.api-sports.io/flags/sa.svg',
    ),
    'event_date' => '2023-01-22T20:30:00+03:00',
    'event_timestamp' => 1674408600,
    'firstHalfStart' => NULL,
    'secondHalfStart' => NULL,
    'round' => 'Regular Season - 14',
    'status' => 'Not Started',
    'statusShort' => 'NS',
    'elapsed' => 0,
    'venue' => 'Mrsool Park',
    'referee' => NULL,
    'homeTeam' =>
    array (
    'team_id' => 2939,
    'team_name' => 'Al-Nassr',
    'logo' => 'https://media.api-sports.io/football/teams/2939.png',
    ),
    'awayTeam' =>
    array (
    'team_id' => 2934,
    'team_name' => 'Al-Ettifaq',
    'logo' => 'https://media.api-sports.io/football/teams/2934.png',
    ),
    'goalsHomeTeam' => NULL,
    'goalsAwayTeam' => NULL,
    'score' =>
    array (
    'halftime' => NULL,
    'fulltime' => NULL,
    'extratime' => NULL,
    'penalty' => NULL,
    ),
    ),

    And here is the code for impor

    J 1 Reply Last reply
    0
    • M Member_15901519

      Hello, I successfully loaded the json responses into an HTML table. However, I am having a problem displaying the images of the json variables. I could only display the links. Here is the output:

      Home Team Match Date Away Team
      https://media-3.api-sports.io/football/teams/2939.png 2023-01-22T20:30:00+03:00 https://media-3.api-sports.io/football/teams/2934.png
      https://media-3.api-sports.io/football/teams/2938.png 2023-01-26T21:00:00+03:00 https://media-3.api-sports.io/football/teams/2939.png
      https://media.api-sports.io/football/teams/2931.png 2023-02-03T17:00:00+03:00 https://media.api-sports.io/football/teams/2939.png
      https://media.api-sports.io/football/teams/2937.png 2023-02-09T19:30:00+03:00 https://media-3.api-sports.io/football/teams/2939.png
      https://media-3.api-sports.io/football/teams/2939.png 2023-02-17T17:00:00+03:00 https://media-3.api-sports.io/football/teams/2936.png

      Here is a sample of the json file:

      array (
      'api' =>
      array (
      'results' => 10,
      'fixtures' =>
      array (
      0 =>
      array (
      'fixture_id' => 932017,
      'league_id' => 4633,
      'league' =>
      array (
      'name' => 'Pro League',
      'country' => 'Saudi-Arabia',
      'logo' => 'https://media-3.api-sports.io/football/leagues/307.png',
      'flag' => 'https://media-3.api-sports.io/flags/sa.svg',
      ),
      'event_date' => '2023-01-22T20:30:00+03:00',
      'event_timestamp' => 1674408600,
      'firstHalfStart' => NULL,
      'secondHalfStart' => NULL,
      'round' => 'Regular Season - 14',
      'status' => 'Not Started',
      'statusShort' => 'NS',
      'elapsed' => 0,
      'venue' => 'Mrsool Park',
      'referee' => NULL,
      'homeTeam' =>
      array (
      'team_id' => 2939,
      'team_name' => 'Al-Nassr',
      'logo' => 'https://media.api-sports.io/football/teams/2939.png',
      ),
      'awayTeam' =>
      array (
      'team_id' => 2934,
      'team_name' => 'Al-Ettifaq',
      'logo' => 'https://media.api-sports.io/football/teams/2934.png',
      ),
      'goalsHomeTeam' => NULL,
      'goalsAwayTeam' => NULL,
      'score' =>
      array (
      'halftime' => NULL,
      'fulltime' => NULL,
      'extratime' => NULL,
      'penalty' => NULL,
      ),
      ),

      And here is the code for impor

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #2

      Looks like an old codebase using PHP and jQuery. Just FYI, rather than dump all your code, perhaps start with just the relevant bits? It shows us you put some effort into this. Anywho, that JSON object will only have a string in it. If that string is a path to an image, you'll have to output that path in its src attribute, similar to the way you're building out that table.

      const output = ``;
      element.innerHTML += output;

      Note: There are better ways to go about this, but I'll save that for a different day.

      Jeremy Falcon

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups