Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-26
5
Medium Priority
?
267 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

916 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