{ bracket is closed properly but firebug complains about it

Discussion in 'Javascript' started by knowledgenotebook, Apr 1, 2011.

  1. May I borrow your eyes for it?

    What I want to do is to post a short text to my FB wall. Thanks.

    <html>
    <head>
    <script src="http://connect.facebook.net/en_us/all.js"></script>
    <script type="text/javascript">

    FB.init({appid: '100001125873988', status: true, cookie: true,xfbml:
    true});


    function shareonWall() {
    FB.getLoginStatus(function(response){
    if (response.session) {
    FB.ui ({
    method: 'stream.publish',
    message: '',
    attachment: {
    name: 'Don',
    caption: 'Communication 303',
    description: ('Clarity, brevity and an understanding of your
    audience.'),
    href: ''
    }
    function (response) {
    if (response && response.post_id)
    {
    alert('The note is published to your FB wall now.');
    }
    };

    });
    }
    else
    {
    alert('Please log in to FB first prior to posting.');
    }

    })
    }

    </script>
    </head>

    <body>
    <input type="button" value="Share" onClick="shareOnWall()"/>
    </body>
    </html>
     
    knowledgenotebook, Apr 1, 2011
    #1
    1. Advertising

  2. Am 2011-04-01 06:50, knowledgenotebook meinte:
    > May I borrow your eyes for it?
    >
    > What I want to do is to post a short text to my FB wall. Thanks.


    [source and markup snipped]

    And the question is?

    Anyway, I'm pretty sure that Firebug tells you *where* in your code it
    misses the curly bracket. Besides, the various JS lints floating around
    will also tell you where they miss the bracket in question [1].
    Finally, when posting such "questions", make sure that your source is
    readable. Your indentation sucks (you can leave out the markup, too),
    and keeps people from risking a seconds look.

    Gregor


    [1]
    Problem at line 13 character 5: Expected '}' to match '{' from line 4
    and instead saw 'function'.


    --
    http://vxweb.net
     
    Gregor Kofler, Apr 1, 2011
    #2
    1. Advertising

  3. On Apr 1, 5:02 am, Gregor Kofler <> wrote:
    > Am 2011-04-01 06:50, knowledgenotebook meinte:
    >
    > > May I borrow your eyes for it?

    >
    > > What I want to do is to post a short text to my FB wall.  Thanks.

    >
    > [source and markup snipped]
    >
    > And the question is?
    >
    > Anyway, I'm pretty sure that Firebug tells you *where* in your code it
    > misses the curly bracket. Besides, the various JS lints floating around
    > will also tell you where they miss the bracket in question [1].
    > Finally, when posting such "questions", make sure that your source is
    > readable. Your indentation sucks (you can leave out the markup, too),
    > and keeps people from risking a seconds look.
    >
    > Gregor
    >
    > [1]
    > Problem at line 13 character 5: Expected '}' to match '{' from line 4
    > and instead saw 'function'.
    >
    > --http://vxweb.net


    Yeah, I used firebug, sorry, forgot to post the exact err msg, it was
    and still is on my ff3.6 and firebug 1.6.2:
    "
    missing } after property list
    [Break On This Error] function (response)
    "
    Line 52

    Why do we get different err msg?

    And according to the debugging info from yours, is the following js
    construct faulty (rusty on this guy now..),

    FB.getLoginStatus(function(response){
    ...
    function(response)
    {
    ...
    }
    })

    Thanks.
     
    knowledgenotebook, Apr 1, 2011
    #3
  4. On Apr 1, 10:26 am, Stefan Weiss <> wrote:
    > On 01/04/11 14:46, knowledgenotebook wrote:
    >
    > > On Apr 1, 5:02 am, Gregor Kofler <> wrote:
    > >> Finally, when posting such "questions", make sure that your source is
    > >> readable. Your indentation sucks (you can leave out the markup, too),
    > >> and keeps people from risking a seconds look.

    >
    > Seconded. With proper indentation, the problem would have been obvious
    > at a glance.
    >
    > >> Problem at line 13 character 5: Expected '}' to match '{' from line 4
    > >> and instead saw 'function'.

    > > missing } after property list
    > > [Break On This Error] function (response)
    > > Why do we get different err msg?

    >
    > Your error message is from Firebug, Gregor's is from JSLint (I assume).
    >
    > > And according to the debugging info from yours, is the following js
    > > construct faulty (rusty on this guy now..),

    >
    > > FB.getLoginStatus(function(response){
    > >   ...
    > >   function(response)
    > >   {
    > >   ...
    > >   }
    > > })

    >
    > No, that's not the problem. What you did was, simplified -
    >
    >     FB.ui({
    >         method: 'stream.publish',
    >         message: '',
    >         attachment: {
    >             name: 'Don',
    >             href: ''
    >         }
    >         function (response) {
    >             // code
    >         };
    >     });
    >
    > That is, you put the callback function right in the middle of the object
    > literal. That's a syntax error. What you meant was -
    >
    >     FB.ui({
    >             method: 'stream.publish',
    >             message: '',
    >             attachment: {
    >                 name: 'Don',
    >                 href: ''
    >             }
    >           },
    >           function (response) {
    >               // code
    >           }
    >     );
    >
    > That's syntactically correct but still not very readable. If your
    > statements get so long and convoluted that you can't even spot syntax
    > errors anymore, you can use temporary variables to improve readability:
    >
    >     var fbOpts = {
    >         method: 'stream.publish',
    >         message: '',
    >         attachment: {
    >             name: 'Don',
    >             href: ''
    >         }
    >     };
    >     var callback = function (response) {
    >         // code
    >     };
    >     FB.ui(fbOpts, fbCallback);
    >
    > --
    > stefan


    Thanks, stepfan, very helpful.

    But now I'm getting the following err msg:
    FB is not defined
    [Break On This Error] FB.init({appid: '100001125873988', status: true,
    cookie: true,xfbml: true});

    How come?
     
    knowledgenotebook, Apr 1, 2011
    #4
  5. Stefan Weiss wrote:

    > knowledgenotebook wrote:
    >> But now I'm getting the following err msg:
    >> FB is not defined
    >> [Break On This Error] FB.init({appid: '100001125873988', status: true,
    >> cookie: true,xfbml: true});
    >>
    >> How come?

    >
    > URLs are case sensitive.


    Wrong. Some parts of URLs (generalized: URIs) are case-sensitive, others
    (like the domain-part) are not. Whether a part of a URL is case-sensitive
    depends on the server-side operating system, filesystem, URL rewrites, and
    the target resource. See also RFC 3986.


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
     
    Thomas 'PointedEars' Lahn, Apr 1, 2011
    #5
  6. On Apr 1, 10:54 am, Stefan Weiss <> wrote:
    > On 01/04/11 16:48, knowledgenotebook wrote:
    >
    > > But now I'm getting the following err msg:
    > > FB is not defined
    > > [Break On This Error] FB.init({appid: '100001125873988', status: true,
    > > cookie: true,xfbml: true});

    >
    > > How come?

    >
    > URLs are case sensitive. Check that URL you used for the Facebook API
    > script (just open it in a browser)...
    >
    > --
    > stefan


    ok, probably someone at FB is play April Fool trick here with the URL,
    I'm using the 'correct' one now.

    Ok, my current code looks like this:

    function shareonWall() {

    FB.init({appid: '100001125873988', status: true, cookie: true,xfbml:
    true});

    FB.getLoginStatus(function(response){
    ....
    }


    No error, data not posted to my FB wall,
    and firebug has the following info under the 'All' tab:
    FB.getLoginStatus() called before calling FB.init().

    So, it appears the FB code library is executed in alph order, that is,
    getLoginStatus (method) is executed first and then
    init (method)
    ....

    How can we make the init method to be executed first?

    Thanks.
     
    knowledgenotebook, Apr 1, 2011
    #6
  7. On Apr 1, 12:37 pm, Stefan Weiss <> wrote:
    > On 01/04/11 17:46, knowledgenotebook wrote:
    >
    >
    >
    > > On Apr 1, 10:54 am, Stefan Weiss <> wrote:
    > >> URLs are case sensitive. Check that URL you used for the Facebook API
    > >> script (just open it in a browser)...

    > > ok, probably someone at FB is play April Fool trick here with the URL,
    > > I'm using the 'correct' one now.

    >
    > > Ok, my current code looks like this:

    >
    > > function shareonWall() {

    >
    > > FB.init({appid: '100001125873988', status: true, cookie: true,xfbml:
    > > true});

    >
    > > FB.getLoginStatus(function(response){
    > > ...
    > > }

    >
    > > No error, data not posted to my FB wall,
    > > and firebug has the following info under the 'All' tab:
    > > FB.getLoginStatus() called before calling FB.init().

    >
    > > So, it appears the FB code library is executed in alph order, that is,
    > > getLoginStatus (method) is executed first and then
    > > init (method)
    > > ...

    >
    > > How can we make the init method to be executed first?

    >
    > I highly doubt that they're called in alphabetical order... but who
    > knows what their script is doing. The message you see in Firebug looks
    > like it was issued from the Facebook script. I can't help you with the
    > Facebook specific parts, as I've never used that API before. Don't they
    > have code examples online somewhere?
    >
    > BTW, you can ignore Thomas Lahn's pedantic "correction" about domain
    > parts in generalized URIs, it completely misses the point. Your problem
    > was that Facebook expected "en_US" in the path, where you wrote "en_us".
    > There are parts in HTTP URLs which will be handled in a case sensitive
    > manner by most web servers, so you should always treat them as case
    > sensitive.
    >
    > --
    > stefan


    stepfan, yes, my current script uses "en_US" as in
    <script src="http://connect.facebook.net/en_US/all.js"></script>

    I've also attempted to load the init function with body tag of onload
    event trigger, all to no avail.

    if Facebook is playing April Fool trick it's time to stop it,
    unproductive for all.

    thanks.
     
    knowledgenotebook, Apr 1, 2011
    #7
  8. Stefan Weiss wrote:

    > BTW, you can ignore Thomas Lahn's pedantic "correction" about domain
    > parts in generalized URIs, it completely misses the point. Your problem
    > was that Facebook expected "en_US" in the path, where you wrote "en_us".


    Which, AISB, is caused by case-sensitive URL rewrite or server-side
    filesystem.

    > There are parts in HTTP URLs which will be handled in a case sensitive
    > manner by most web servers, so you should always treat them as case
    > sensitive.


    You cannot draw that conclusion. What you only can say for sure
    is that some servers treat some parts of URIs case-sensitively.


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Apr 2, 2011
    #8
  9. Thomas 'PointedEars' Lahn <> writes:

    > Stefan Weiss wrote:
    >
    >> There are parts in HTTP URLs which will be handled in a case sensitive
    >> manner by most web servers, so you should always treat them as case
    >> sensitive.

    >
    > You cannot draw that conclusion. What you only can say for sure
    > is that some servers treat some parts of URIs case-sensitively.


    Are you arguing that "some" is not the same as "most"?
    Do you have data to support that it's not actually "most"?

    But still, if only some servers treat some parts of URIs as case
    sensitive, I also think it's to be recommended that the client treat
    those parts as if they *might* be case-sensitive.

    Which was what Stefan Weiss said.

    Even if you know that the web server you are accessing is
    case-insensitive on the part of the URL that you are creating,
    creating different capitalizations of the part is a bad idea,
    since it locks you to that web-server. If you pick a consistent
    capitalization, you can change the server later without having
    to review all you client code.

    /L
    --
    Lasse Reichstein Holst Nielsen
    'Javascript frameworks is a disruptive technology'
     
    Lasse Reichstein Nielsen, Apr 2, 2011
    #9
  10. knowledgenotebook

    VK Guest

    On Apr 1, 9:03 pm, knowledgenotebook <> wrote:
    > if Facebook is playing April Fool trick it's time to stop it,
    > unproductive for all.


    They are not playing fools, they are ones - so it is perpetual. The
    API says ( http://developers.facebook.com/docs/reference/javascript/
    ) : "You must specify a <div> element named fb-root within the
    document".
    What id doesn't tell you that:
    1) no DIV[id="fb-root"] - no init
    2) no init - the whole FB library object falls apart with random
    cryptic messages ("not initialized" || "not defined" || "bracket
    missing" etc.): because the situation that DIV[id="fb-root"] is
    missing or not accessible was not considered as an option.
    3) FB library is using document.write so initializes before page load
    event
    4) before page load event it cannot access document.getElementById
    because the DOM is not fully accessible so it cannot check if
    DIV[id="fb-root"] is presented: so if the library in the document
    <head> section, you can place a dozen DIV[id="fb-root"] on your page
    and it still will not see it and see outcome (1)(2).
    5) Because of (4) FB has to relay on the known quirk in all prominent
    browsers when DOM is partially exposed even before page load from the
    beginning and up to the point from where the script call is made.
    6) Some people are created to be great writers, backers, janitors and
    anything else but Javascript programmers. Yet they do believe that
    they are Javascript programmers and Facebook takes them to the team
    for whatever reason. As they result we having unhappy people doing
    something they are not created to do - and unhappy customers forced to
    deal with products of such people activity.

    Because of (1)-(6) in order to use FB library you need to:

    1) place <div id="fb-root"></div> on your page
    2) place FB library anywhere *after* that DIV
    3) no, you cannot have it in the head section
     
    VK, Apr 2, 2011
    #10
  11. knowledgenotebook

    VK Guest

    On Apr 2, 4:07 pm, VK <> wrote:
    > 6) Some people are created to be great writers, backers, janitors and
    > anything else but Javascript programmers. Yet they do believe that
    > they are Javascript programmers and Facebook takes them to the team
    > for whatever reason. As they result we having unhappy people doing
    > something they are not created to do - and unhappy customers forced to
    > deal with products of such people activity.


    There is even something darling to see people having no slightest clue
    about the job they are doing yet bravely doing it...

    http://developers.facebook.com/docs/reference/javascript/
    ....
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    ....


    all.js
    ....
    FB.Content._root=c=FB.$('fb-root')
    ....
    $:function(a){return document.getElementById(a);}}
    ....

    Sapienti sat.

    If placing FB to the <head> is a must it can be a quirk like:

    <script id="fb-root" src="http://connect.facebook.net/en_US/all.js"></
    script>

    It lets the "library" to init OK - but for for all outcomes of using
    script with id in the head instead of div with id in the body - I am
    washing my hands.
     
    VK, Apr 2, 2011
    #11
  12. Stefan Weiss wrote:

    > On 02/04/11 12:44, Thomas 'PointedEars' Lahn wrote:
    >> Lasse Reichstein Nielsen wrote:
    >>> Thomas 'PointedEars' Lahn <> writes:
    >>>> Stefan Weiss wrote:
    >>>>> There are parts in HTTP URLs which will be handled in a case sensitive
    >>>>> manner by most web servers, so you should always treat them as case
    >>>>> sensitive.
    >>>> You cannot draw that conclusion. What you only can say for sure
    >>>> is that some servers treat some parts of URIs case-sensitively.
    >>> Are you arguing that "some" is not the same as "most"?

    >> I am arguing that arguments using "most" without giving a rationale are
    >> fallacious.

    >
    > I thought that was common knowledge, but here you go:
    >
    > Apache 69.4%
    > Microsoft-IIS 19.6%
    > http://w3techs.com/technologies/overview/web_server/all
    >
    > Unix 64.1%
    > Windows 35.9%
    > http://w3techs.com/technologies/overview/operating_system/all


    I can see the reason for your misconception now.

    > Not that it really matters.


    True, your "evidence" does not matter.

    > It would be enough to know that "some" don't use case folding.


    That still does not make your statement about URIs correct.


    HTH

    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Apr 2, 2011
    #12
  13. In comp.lang.javascript message <rbSdnbw_6-Y2fQjQnZ2dnUVZ8qGdnZ2d@gigane
    ws.com>, Fri, 1 Apr 2011 16:26:49, Stefan Weiss <>
    posted:

    >On 01/04/11 14:46, knowledgenotebook wrote:
    >> On Apr 1, 5:02 am, Gregor Kofler <> wrote:
    >>> Finally, when posting such "questions", make sure that your source is
    >>> readable. Your indentation sucks (you can leave out the markup, too),
    >>> and keeps people from risking a seconds look.

    >
    >Seconded. With proper indentation, the problem would have been obvious
    >at a glance.


    That depends on whether the indentation that is actually present
    reflects the authors intentions or the code actually present. It is the
    difference between these two that is the source of the problem.

    Code, preferably without spurious line breaks, can be pasted into a
    LOCAL COPY of <http://www.merlyn.demon.co.uk/js-quick.htm> and
    systematically indented by pressing a button.

    The code which does that does not understand much JavaScript, so (IIRC)
    if you have a string containing unmatched braces, you will want to help
    by putting the matching braces in end-of-line comment.

    A copy of W3 TIDY, from sourceforge, should do better.

    --
    (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
    Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
    PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
    Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
     
    Dr J R Stockton, Apr 2, 2011
    #13
  14. knowledgenotebook

    VK Guest

    On Apr 2, 1:49 pm, Lasse Reichstein Nielsen <>
    wrote:
    > But still, if only some servers treat some parts of URIs as case
    > sensitive, I also think it's to be recommended that the client treat
    > those parts as if they *might* be case-sensitive.  


    Correction: what parts of URL are we talking about? The case
    sensitivity might be exposed *only* for the location.search part.
    Anything else is technically possible but is extremely unprofessional.
    No one prevents to set a server in the way that
    HTTP://wWw.example.com
    http://WWW.example.com
    http://www.example.com
    would redirect to different pages yet show me a moron who would set it
    in such way. Oh sorry - a splendid sample is given right in this
    thread using FB service...

    http://www.ietf.org/rfc/rfc1738.txt
    2.1. The main parts of URLs
    For resiliency, programs interpreting URLs should treat upper case
    letters as equivalent to lower case in scheme names (e.g., allow
    "HTTP" as well as "http").

    Yes, "should" is not "must" but a a good part of the modern Web
    integrity is based on that "should" treated exactly as "must".
     
    VK, Apr 3, 2011
    #14
  15. knowledgenotebook

    beegee Guest

    On Apr 1, 1:03 pm, knowledgenotebook <> wrote:
    avail.
    >
    > if Facebook is playing April Fool trick it's time to stop it,
    > unproductive for all.
    >
    > thanks.



    I believe you must have, as the first tag after the <body>
    <div id="fb_root"></div>

    all.js looks to this to attach itself to. Highly offtopic but there
    ya go.

    bob
     
    beegee, Apr 3, 2011
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2lycGVsaWRvcg==?=

    debugger complains: auto-attach to process 'aspnet_wp.exe'

    =?Utf-8?B?c2lycGVsaWRvcg==?=, Aug 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    2,165
    =?Utf-8?B?c2lycGVsaWRvcg==?=
    Aug 29, 2005
  2. Replies:
    1
    Views:
    2,541
    Jonathan N. Little
    Jun 22, 2006
  3. David Sudolcan
    Replies:
    7
    Views:
    2,214
    Eric Sosman
    Apr 4, 2011
  4. Matt Kruse
    Replies:
    5
    Views:
    334
    Richard Cornford
    Sep 9, 2003
  5. daveyand
    Replies:
    4
    Views:
    500
    Tad McClellan
    May 24, 2006
Loading...

Share This Page