Loading ...
Sorry, an error occurred while loading the content.

JSON and Firefox Javascript Console

Expand Messages
  • mhyk14
    Hi, I m trying out JSON and I find it really easy to produce and manipulate. But I have some concerns regarding FireFox s Javascript Console. I m using 1.5
    Message 1 of 8 , Jan 27, 2006
    • 0 Attachment
      Hi,

      I'm trying out JSON and I find it really easy to produce and
      manipulate. But I have some concerns regarding FireFox's Javascript
      Console. I'm using 1.5 btw, PHP-JSON and json.js from json.org.

      Everytime I try to pass back a json string from a PHP script using
      "echo", I always get an error message on FFox's Javascript Console.

      QUOTE
      Error: syntax error
      Source File: http://localhost/ajax/answer.php?state=Colorado
      Line: 1, Column: 1
      Source Code:
      [{"stateid":"CO","city":"Alamosa"},{"stateid":"CO","city":"Arvada"},{"stateid":"CO","city":"Aspen"},{"stateid":"CO","city":"Aurora"},{"stateid":"CO","city":"Avon"},{"stateid":"CO","city":"Bailey"},{"stateid":"CO","city":"Basalt"},{"stateid":"CO","city":"Berthoud"},{"stateid":"CO","city":"Boulder"},{"stateid":"CO","city":"Breckenridge"},{"stateid":"CO","city":"Brighton"},{"stateid":"CO","city":"Broomfield"},{"stateid":"CO","city":"Brush"},{"stateid":"CO","city":"Buena
      Vista"},{"stateid":"CO","city":"Burlington"},{"stateid":"CO","city":"Canon
      City"}]^


      Can someone please tell me if this is a FireFox issue or is my json
      string is really invalid. I also get errors when returning XML so...

      Thanks
    • Martin Cooper
      ... Well there seems to be a funky ^ after the array, which wouldn t be valid if it s part of what you re sending back. -- Martin Cooper I also get errors
      Message 2 of 8 , Jan 27, 2006
      • 0 Attachment
        On 1/27/06, mhyk14 <mhyk14@...> wrote:
        >
        > Hi,
        >
        > I'm trying out JSON and I find it really easy to produce and
        > manipulate. But I have some concerns regarding FireFox's Javascript
        > Console. I'm using 1.5 btw, PHP-JSON and json.js from json.org.
        >
        > Everytime I try to pass back a json string from a PHP script using
        > "echo", I always get an error message on FFox's Javascript Console.
        >
        > QUOTE
        > Error: syntax error
        > Source File: http://localhost/ajax/answer.php?state=Colorado
        > Line: 1, Column: 1
        > Source Code:
        >
        > [{"stateid":"CO","city":"Alamosa"},{"stateid":"CO","city":"Arvada"},{"stateid":"CO","city":"Aspen"},{"stateid":"CO","city":"Aurora"},{"stateid":"CO","city":"Avon"},{"stateid":"CO","city":"Bailey"},{"stateid":"CO","city":"Basalt"},{"stateid":"CO","city":"Berthoud"},{"stateid":"CO","city":"Boulder"},{"stateid":"CO","city":"Breckenridge"},{"stateid":"CO","city":"Brighton"},{"stateid":"CO","city":"Broomfield"},{"stateid":"CO","city":"Brush"},{"stateid":"CO","city":"Buena
        > Vista"},{"stateid":"CO","city":"Burlington"},{"stateid":"CO","city":"Canon
        > City"}]^
        >
        >
        > Can someone please tell me if this is a FireFox issue or is my json
        > string is really invalid.


        Well there seems to be a funky '^' after the array, which wouldn't be valid
        if it's part of what you're sending back.

        --
        Martin Cooper


        I also get errors when returning XML so...
        >
        > Thanks
        >
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Gordon Mohr (@ Bitzi)
        ... There s also the strange &q uot; , though perhaps that s an artifact of something else. - Gordon
        Message 3 of 8 , Jan 27, 2006
        • 0 Attachment
          Martin Cooper wrote:
          > On 1/27/06, mhyk14 <mhyk14@...> wrote:
          > >
          > > Hi,
          > >
          > > I'm trying out JSON and I find it really easy to produce and
          > > manipulate. But I have some concerns regarding FireFox's Javascript
          > > Console. I'm using 1.5 btw, PHP-JSON and json.js from json.org.
          > >
          > > Everytime I try to pass back a json string from a PHP script using
          > > "echo", I always get an error message on FFox's Javascript Console.
          > >
          > > QUOTE
          > > Error: syntax error
          > > Source File: http://localhost/ajax/answer.php?state=Colorado
          > > Line: 1, Column: 1
          > > Source Code:
          > >
          > >
          > [{"stateid":"CO","city":"Alamosa"},{"stateid":"CO","city":"Arvada"},{"stateid":"CO","city":"Aspen"},{"stateid":"CO","city":"Aurora"},{"stateid":"CO","city":"Avon"},{"stateid":"CO","city":"Bailey"},{"stateid":"CO","city":"Basalt"},{"stateid":"CO","city":"Berthoud"},{"stateid":"CO","city":"Boulder"},{"stateid":"CO","city":"Breckenridge"},{"stateid":"CO","city":"Brighton"},{"stateid":"CO","city":"Broomfield"},{"stateid":"CO","city":"Brush"},{"stateid":&q
          > uot;CO","city":"Buena
          > >
          > Vista"},{"stateid":"CO","city":"Burlington"},{"stateid":"CO","city":"Canon
          > > City"}]^
          > >
          > >
          > > Can someone please tell me if this is a FireFox issue or is my json
          > > string is really invalid.
          >
          >
          > Well there seems to be a funky '^' after the array, which wouldn't be valid
          > if it's part of what you're sending back.

          There's also the strange "&q uot;", though perhaps that's an artifact of
          something else.

          - Gordon
        • mhyk14
          Thanks for the replies. Here s another error message from FireFox s Javascript Console: Error: syntax error Source File:
          Message 4 of 8 , Jan 27, 2006
          • 0 Attachment
            Thanks for the replies. Here's another error message from FireFox's
            Javascript Console:

            Error: syntax error
            Source File: http://localhost/ajax/answer.php?state=empty
            Line: 1, Column: 1
            Source Code:
            [{"stateid":"WY","states":[{"state":"Alabama"},{"state":"Alaska"},{"state":"Arizona"},{"state":"Arkansas"},{"state":"California"},{"state":"Colorado"},{"state":"Connecticut"},{"state":"Delaware"},{"state":"Florida"},{"state":"Georgia"},{"state":"Hawaii"},{"state":"Idaho"},{"state":"Illinois"},{"state":"Indiana"},{"state":"Iowa"},{"state":"Kansas"},{"state":"Kentucky"},{"state":"Louisiana"},{"state":"Maine"},{"state":"Maryland"},{"state":"Massachusetts"},{"state":"Michigan"},{"state":"Minnesota"},{"state":"Mississippi"},{"state":"Missouri"},{"state":"Montana"},{"state":"Nebraska"},{"state":"Nevada"},{"state":"New
            Hampshire"},{"state":"New Jersey"},{"state":"New
            Mexico"},{"state":"New York"},{"state":"North
            Carolina"},{"state":"North
            Dakota"},{"state":"Ohio"},{"state":"Oklahoma"},{"state":"Oregon"},{"state":"Pennsylvania"},{"state":"Rhode
            Island"},{"state":"South Carolina"},{"state":"South
            Dakota"},{"state":"Tennessee"},{"state":"Texas"},{"state":"Utah"},{"state":"Vermont"},{"state":"Virginia"},{"state":"Washington"},{"state":"West
            Virginia"},{"state":"Wisconsin"},{"state":"Wyoming"}]}]^

            the ^ character must be part of FF's JS Console because when I view
            the page directly, that character doesn't show up.

            Thanks,
            Mike
          • Michal Migurski
            ... The JSON string looks fine. Could it be that you are just evaluating it directly in the browser, without adding any context such as var foo = [...]; ?
            Message 5 of 8 , Jan 28, 2006
            • 0 Attachment
              > I'm trying out JSON and I find it really easy to produce and
              > manipulate. But I have some concerns regarding FireFox's Javascript
              > Console. I'm using 1.5 btw, PHP-JSON and json.js from json.org.
              >
              > Everytime I try to pass back a json string from a PHP script using
              > "echo", I always get an error message on FFox's Javascript Console.

              The JSON string looks fine. Could it be that you are just evaluating
              it directly in the browser, without adding any context such as "var
              foo = [...];" ?

              ----------------------------------------------------------------
              michal migurski- contact info and pgp key:
              sf/ca http://mike.teczno.com/contact.html
            • Mike D
              well, here s the line that grabs the json string: var jsonObj = JSON.parse(http.responseText); fyi: Im using the JSON Parser from json.org Do you think I/we
              Message 6 of 8 , Jan 28, 2006
              • 0 Attachment
                well, here's the line that grabs the json string:
                var jsonObj = JSON.parse(http.responseText);

                fyi: Im using the JSON Parser from json.org

                Do you think I/we should consider this an FF issue since the errors doesn't show up on IE and Opera and it is functioning pretty well? I was just concerned that there might be something wrong with my json string.

                Thanks

                Michal Migurski <mike-jsonphp@...> wrote: > I'm trying out JSON and I find it really easy to produce and
                > manipulate. But I have some concerns regarding FireFox's Javascript
                > Console. I'm using 1.5 btw, PHP-JSON and json.js from json.org.
                >
                > Everytime I try to pass back a json string from a PHP script using
                > "echo", I always get an error message on FFox's Javascript Console.

                The JSON string looks fine. Could it be that you are just evaluating
                it directly in the browser, without adding any context such as "var
                foo = [...];" ?

                ----------------------------------------------------------------
                michal migurski- contact info and pgp key:
                sf/ca http://mike.teczno.com/contact.html





                SPONSORED LINKS
                Json Programming languages Format Computer security Computer training Large format

                ---------------------------------
                YAHOO! GROUPS LINKS


                Visit your group "json" on the web.

                To unsubscribe from this group, send an email to:
                json-unsubscribe@yahoogroups.com

                Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


                ---------------------------------





                Send instant messages to your online friends http://uk.messenger.yahoo.com

                [Non-text portions of this message have been removed]
              • Jim Washington
                ... What content-type are you sending with your JSON? Is there a charset involved? I ve found that similar I can t parse this issues are sometimes resolved
                Message 7 of 8 , Jan 28, 2006
                • 0 Attachment
                  Mike D wrote:

                  >well, here's the line that grabs the json string:
                  >var jsonObj = JSON.parse(http.responseText);
                  >
                  >fyi: Im using the JSON Parser from json.org
                  >
                  >Do you think I/we should consider this an FF issue since the errors doesn't show up on IE and Opera and it is functioning pretty well? I was just concerned that there might be something wrong with my json string.
                  >
                  >
                  What content-type are you sending with your JSON? Is there a charset
                  involved?

                  I've found that similar "I can't parse this" issues are sometimes
                  resolved if you use "application/x-javascript" for content-type.

                  Worth a try, at least.

                  -Jim Washington
                • Mike D
                  lol I give up. I tried using several charsets along with text/plain, text/javascript, application/x-javascript, application/javascript and
                  Message 8 of 8 , Jan 28, 2006
                  • 0 Attachment
                    lol I give up. I tried using several charsets along with text/plain, text/javascript, application/x-javascript, application/javascript and application/x-_javascript but the error is still there.

                    The JSON object gets parsed perfectly though. I just hate seeing these errors on my JS Console everytime I test the page.

                    Thanks

                    Jim Washington <jwashin@...> wrote: Mike D wrote:

                    >well, here's the line that grabs the json string:
                    >var jsonObj = JSON.parse(http.responseText);
                    >
                    >fyi: Im using the JSON Parser from json.org
                    >
                    >Do you think I/we should consider this an FF issue since the errors doesn't show up on IE and Opera and it is functioning pretty well? I was just concerned that there might be something wrong with my json string.
                    >
                    >
                    What content-type are you sending with your JSON? Is there a charset
                    involved?

                    I've found that similar "I can't parse this" issues are sometimes
                    resolved if you use "application/x-javascript" for content-type.

                    Worth a try, at least.

                    -Jim Washington


                    ---------------------------------
                    YAHOO! GROUPS LINKS


                    Visit your group "json" on the web.

                    To unsubscribe from this group, send an email to:
                    json-unsubscribe@yahoogroups.com

                    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


                    ---------------------------------





                    Send instant messages to your online friends http://uk.messenger.yahoo.com

                    [Non-text portions of this message have been removed]
                  Your message has been successfully submitted and would be delivered to recipients shortly.