Solved

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

Posted on 2013-06-26
5
254 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
Comment Utility
On lines 16-18, try changing:
... ? picName : 'Players/Blank.gif'

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

Expert Comment

by:Tom Beck
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I screwed up I had the path set to local and not network so it works right. Thanks anyway!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

771 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

12 Experts available now in Live!

Get 1:1 Help Now