?
Solved

SNYTAX ERROR JAVASCRIPT

Posted on 2014-03-24
8
Medium Priority
?
225 Views
Last Modified: 2014-03-24
i'M CONVERTING INTERNAL WEB PAGE JAVASCRIPTS AND MAKING THEM EXTERNAL. And I'M MISSING SOMETHING AGAIN PLEASE HELP EASY 500

// JavaScript Document
 var QueryString = function () {
	var query_string = {};
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		// If first entry with this name
		if (typeof query_string[pair[0]] === "undefined") {
			query_string[pair[0]] = pair[1];
		// If second entry with this name
		} else if (typeof query_string[pair[0]] === "string") {
			var arr = [ query_string[pair[0]], pair[1] ];
			query_string[pair[0]] = arr;
		// If third or later entry with this name
		} else {
			query_string[pair[0]].push(pair[1]);
		}
	} 
	return query_string;
} ();  
var xmlPath = '/xml/mlb/scores/real';
var xmlGameID =  QueryString.gameID;
function startup(){
    $.ajax({
        type: "GET",
        url:  xmlPath+"/"+xmlGameID+ ".xml",
        dataType: "xml",
        success: function(data) {
            var d = $(data);
            d.find('Team').each(function(i,Team){
                var team=$(Team);
                var id = team.attr("ID").toLowerCase();
                var teamname = team.attr("name");
                var homeOrAway = team.attr("vh");
               
                var d = $(data);
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "H") {

                       $('#hometeam').attr('src', 'http://sportsnetwork.com/gamecast/images/MLB PS/'+$(Team).attr('ID')+".png");
//}

					 var HS1 = $(Team).find('Linescore');
         // var hs2 = HS1.attr('Score');
          $('#HS').html(HS1.attr('Runs'));
		  }
                })
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "A") {

                    $('#awayteam').attr('src', 'http://sportsnetwork.com/gamecast/images/MLB PS/'+$(Team).attr('ID')+".png");
//}

					 var VS1 = $(Team).find('Linescore');
         // var vs2 = VS1.attr('Score');
          $('#VS').html(VS1.attr('Runs'));
		  }
                });
            });
        var myVar = setInterval(loadData, 1000);
        }
		
    });
	
});


   function loadData() {
  $.ajax({
    type: "GET",
    url:  xmlPath+"/"+xmlGameID+".xml",
    dataType: "xml",
    success: function(data) {
      var d = $(data);
      var Play = d.find('Play');
      d.find('Team').each(function(i,Team){

        if ($(Team).attr('vh') == "A") {

$('#awayteam').attr('src', 'http://sportsnetwork.com/gamecast/images/MLB PS/'+$(Team).attr('ID')+".png");


		  var VS1 = $(Team).find('Linescore');
         
          $('#VS').html(VS1.attr('Runs'));

		 

        }
		 var d = $(data);
		 d.find('Team').each(function(i,Team){
        if ($(Team).attr('vh') == "H") {

          var HS1 = $(Team).find('Linescore');
         
          $('#HS').html(HS1.attr('Runs'));
		$('#hometeam').attr('src', 'http://sportsnetwork.com/gamecast/images/MLB PS/'+$(Team).attr('ID')+".png");
         


        }
     });
	  });// each
        // changed all below to just use the variables that contain the text directly, as the arrays do not exist and don't seem necessary in this situation
      // quarter[qtr]
     // ++counterXml;
    }
  }); //ajax

  }

Open in new window

0
Comment
Question by:powerztom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39950790
...and the error is???
0
 

Author Comment

by:powerztom
ID: 39951088
Gary i'm missing a bracket or brace?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39951109
The function startup(){} has an extra closing bracket - line 66 in your code above.
0
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 

Author Comment

by:powerztom
ID: 39951149
then I get a syntax error on 112.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39951171
Did you remove the bracket or the curly? Remove the bracket -> )
0
 

Author Comment

by:powerztom
ID: 39951374
Just a error sits at 112

var xmlPath = '/xml/mlb/scores/real';
var xmlGameID = '41593';
function startup() {
    $.ajax({
        type: "GET",
        url:  xmlPath+"/"+xmlGameID+ ".xml",
        dataType: "xml",
        success: function(data) {
            var d = $(data);
            d.find('Team').each(function(i,Team){
                var team=$(Team);
                var id = team.attr("ID").toLowerCase();
                var teamname = team.attr("name");
                var homeOrAway = team.attr("vh");
               
                var d = $(data);
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "H") {

                       $('#hometeam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");
//}

					 var HS1 = $(Team).find('Linescore');
         // var hs2 = HS1.attr('Score');
          $('#HS').html(HS1.attr('Runs'));
		  }
                })
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "A") {

                    $('#awayteam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");
//}

					 var VS1 = $(Team).find('Linescore');
         // var vs2 = VS1.attr('Score');
          $('#VS').html(VS1.attr('Runs'));
		  }
                });
            });
        var myVar = setInterval(loadData, 2000);
        }
    });

   function loadData() {
  $.ajax({
    type: "GET",
    url:  xmlPath+"/"+xmlGameID+".xml",
    dataType: "xml",
    success: function(data) {
      var d = $(data);
      var Play = d.find('Play');
      d.find('Team').each(function(i,Team){

        if ($(Team).attr('vh') == "A") {

$('#awayteam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");


		  var VS1 = $(Team).find('Linescore');
         
          $('#VS').html(VS1.attr('Runs'));

		 

        }
		 var d = $(data);
		 d.find('Team').each(function(i,Team){
        if ($(Team).attr('vh') == "H") {

          var HS1 = $(Team).find('Linescore');
         
          $('#HS').html(HS1.attr('Runs'));
		$('#hometeam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");
         


        }
     });
	  });// each
        // changed all below to just use the variables that contain the text directly, as the arrays do not exist and don't seem necessary in this situation
      // quarter[qtr]
     // ++counterXml;
    }
  }); //ajax

  }

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39951385
var xmlPath = '/xml/mlb/scores/real';
var xmlGameID = '41593';
function startup() {
    $.ajax({
        type: "GET",
        url:  xmlPath+"/"+xmlGameID+ ".xml",
        dataType: "xml",
        success: function(data) {
            var d = $(data);
            d.find('Team').each(function(i,Team){
                var team=$(Team);
                var id = team.attr("ID").toLowerCase();
                var teamname = team.attr("name");
                var homeOrAway = team.attr("vh");
               
                var d = $(data);
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "H") {

                       $('#hometeam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");
//}

					 var HS1 = $(Team).find('Linescore');
         // var hs2 = HS1.attr('Score');
          $('#HS').html(HS1.attr('Runs'));
		  }
                })
                d.find('Team').each(function(i,Team){
                    if ($(Team).attr('vh') == "A") {

                    $('#awayteam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");
//}

					 var VS1 = $(Team).find('Linescore');
         // var vs2 = VS1.attr('Score');
          $('#VS').html(VS1.attr('Runs'));
		  }
                });
            });
        var myVar = setInterval(loadData, 2000);
        }
    });
}
   function loadData() {
  $.ajax({
    type: "GET",
    url:  xmlPath+"/"+xmlGameID+".xml",
    dataType: "xml",
    success: function(data) {
      var d = $(data);
      var Play = d.find('Play');
      d.find('Team').each(function(i,Team){

        if ($(Team).attr('vh') == "A") {

$('#awayteam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");


		  var VS1 = $(Team).find('Linescore');
         
          $('#VS').html(VS1.attr('Runs'));

		 

        }
		 var d = $(data);
		 d.find('Team').each(function(i,Team){
        if ($(Team).attr('vh') == "H") {

          var HS1 = $(Team).find('Linescore');
         
          $('#HS').html(HS1.attr('Runs'));
		$('#hometeam').attr('src', 'http://images.sportsnetwork.com/MLB/ATTHEBALLPARK/MLB/'+$(Team).attr('ID')+".png");
         


        }
     });
	  });// each
        // changed all below to just use the variables that contain the text directly, as the arrays do not exist and don't seem necessary in this situation
      // quarter[qtr]
     // ++counterXml;
    }
  }); //ajax

  }

Open in new window

0
 

Author Closing Comment

by:powerztom
ID: 39951498
Gary thank you for swifting through my code and eliminating syntaxv errors. I have like 3 or 4 more to go.I'mm a vb script guy with not being useded to brackets and braces.Thanks Gary
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

770 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