Solved

SNYTAX ERROR JAVASCRIPT

Posted on 2014-03-24
8
217 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
  • 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
 

Author Comment

by:powerztom
ID: 39951149
then I get a syntax error on 112.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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 500 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

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

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.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
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)

914 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

18 Experts available now in Live!

Get 1:1 Help Now