Solved

SNYTAX ERROR JAVASCRIPT

Posted on 2014-03-24
8
223 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
migrating to phpbb forum from vBulletin 4.2 3 40
ASP AND XML 3 30
Hide and Unhide Table 6 27
HTML or/and CSS codes to construct numbered paragraphs. 5 21
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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.

726 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