Solved

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

Posted on 2013-06-26
5
256 Views
Last Modified: 2013-07-01
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
0
Comment
Question by:powerztom
  • 3
5 Comments
 
LVL 82

Expert Comment

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

to:
... ? picName : baseUrlBatterLR + 'Blank.gif'
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39278885
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.
0
 

Author Comment

by:powerztom
ID: 39278944
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
0
 

Accepted Solution

by:
powerztom earned 0 total points
ID: 39279065
I screwed up I had the path set to local and not network so it works right. Thanks anyway!
0
 

Author Closing Comment

by:powerztom
ID: 39289418
I screwed up I had the path set to local and not network so it works right. Thanks anyway!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now