Solved

SNYTAX ERROR JAVASCRIPT

Posted on 2014-03-24
8
213 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

20 Experts available now in Live!

Get 1:1 Help Now