Link to home
Start Free TrialLog in
Avatar of Tom Powers
Tom Powers

asked on

Can't Load image for background and can't load batter image

I can't load a image in a table and I have two apdivs for a right handed batter image or left handed batter image. This did work however something is off for the image in the table i'm loading a image into a image.

$(document).ready(function(){
  $.ajax({
    type: "GET",
    url: xmlPath+"/"+xmlGameID+".xml",
	
    dataType: "xml",
    success: function(data){
      var Teams = $(data).find("Team");
	  
      $.each(Teams,function(i,Team) {
        team=$(Team);
        var id = team.attr("ID").toLowerCase();
       
        var homeOrAway = team.attr("vh");
	var name = team.attr("name").toLowerCase();
       // $("#team"+homeOrAway).append(teamLogo);
        if (homeOrAway=="H") {
          var stadium_location = stadiums[homeTurf[name]]; // or have
          var url = "http://199.233.14.112/aspdata/mlb2/New/Staduimssmall/";
         
          url = (stadium_location) ?url + stadium_location:"AT&T Park.jpg";
				$("#imgStad").attr("src",url)
		  //$('body').css('background-image', 'url(\''+url+'\')');
		  //$("#imgStad").attr("src",url)
        }  


      });
     }
  });

Open in new window


This should load the batter I did but now it's not attached is the xml file which has necessary data


function loadData() {
    $.ajax({
      type: "GET",
      url: xmlPath+"/"+xmlGameID+".xml",
      dataType: "xml",
      success: function(data){
       
        //var intOuts = d.find('Play').attr("Outs") || 0;
        //$('#Outs').attr('src', arrStrikeImages[intOuts]);
        
		var baseUrlBatterLR = 'http://199.233.14.112/aspdata/mlb2/New/Players/'; // or some other directory you decide on
var d = $(data);
var Batter = $(d.find('Batter'));
var bat = Batter.attr("Bats");
var picName = baseUrlBatterLR + 'Batter' + bat + Batter.attr('TeamID') + '.png'; // so for team 12345 you need BatterL12345.png and BatterR12345.png
$('#batterLeft').attr('src', bat=="L" ? picName : 'Players/Blank.gif');
$('#batterRight').attr('src', bat=="R" ? picName : 'Players/Blank.gif');
$('#batterRight').attr('src', bat=="S" ? picName : 'Players/Blank.gif');
	 },

      error: function() {
      }

    });
  }

Open in new window


Can't figure this one out.
36845.xml
Slugger.html
Avatar of hielo
hielo
Flag of Wallis and Futuna image

On lines 16-18, try changing:
... ? picName : 'Players/Blank.gif'

to:
... ? picName : baseUrlBatterLR + 'Blank.gif'
Does the actual path to an image display the image in a browser?

Example:

http://199.233.14.112/aspdata/mlb2/New/Players/BatterL12345.png

Add

alert(picName);

after line 15 to see if the value of picName is a valid URL.
Avatar of Tom Powers
Tom Powers

ASKER

Actually the naming convention for the batter is Batter+L+ "Left" Team id.png Team ID IS in xml. But First I gotta get the staduim to load. BatterL029.png
so http://199.233.14.112/aspdata/mlb2/New/Players/BatterL029.png 

Here is live look at Slugger Giants Staduim comes up Giants Staduim is the default it should load Marlins.jpg http://199.233.14.112/aspdata/mlb2/round3.html
http://199.233.14.112/aspdata/mlb2/index.html
ASKER CERTIFIED SOLUTION
Avatar of Tom Powers
Tom Powers

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I screwed up I had the path set to local and not network so it works right. Thanks anyway!