SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is wrong with this line?

    Hi I have this line

    Code:
    var datasets = xmlhttp.responseText.match(/^#(.[^#]*)/gm).map(function(item) { return eval("(" + item.replace(/^#/,'') + ")"}));
    But it complains and says that is is expecting another ')' so where is the problem? :P

    You can check the script here

    http://www.tdsoft.se

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,892
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    Whenever I get an error like that and I really don't see it, I start smearing the code over as many lines as possible, indenting on every (, ), { and }. Usually that will make the error obvious fairly fast.

    In this case

    Code:
    var datasets = 
    xmlhttp.responseText.match
    (
    	/^#(.[^#]*)/gm).map
    	(
    		function(item)
    		{
    			return eval
    			(
    				"(" + item.replace
    					(
    						/^#/,''
    					)
    				 + ")"
    			// there should be a closing parenthesis here, but there isn't !!
    		}
    
    	)
    );
    So it should be:
    Code:
    var datasets = xmlhttp.responseText.match(/^#(.[^#]*)/gm).map(function(item) { return eval("(" + item.replace(/^#/,'') + ")") }));
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •