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

Re: [json] Re: Looking for help with syntax error

Expand Messages
  • Andrew Faulds
    You might want to JSLint your code, looks like there s some missing semicolons in there, and JSLint might spot what we haven t. ... -- Andrew Faulds (AJF)
    Message 1 of 12 , Jul 11, 2012
    • 0 Attachment
      You might want to JSLint your code, looks like there's some missing
      semicolons in there, and JSLint might spot what we haven't.

      On 11 July 2012 23:41, Reaus@... <reaus@...> wrote:

      > **
      >
      >
      >
      >
      > I didn't think so, but I went ahead and put the
      >
      > <meta http-equiv="X-UA-Compatible" content="IE=8" />
      > tag into my master page and tested it. I did a view source first and
      > verified that the meta tag was there, but I get the same 2 js syntax errors.
      >
      > So frustrating!
      >
      > Thanks for the tip though!
      >
      > ________________________________
      > From: Mark Ingalls <mark_ingalls@...>
      > To: json@yahoogroups.com
      > Sent: Wednesday, July 11, 2012 4:57 PM
      > Subject: RE: [json] Re: Looking for help with syntax error
      >
      >
      >
      >
      > Just a stab in the dark here, but could the response from the QA server be
      > putting your browser into IE 7 mode?
      >
      >
      > http://stackoverflow.com/questions/4715373/json-not-defined-internet-explorer-8
      >
      > From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of
      > Reaus@...
      > Sent: Wednesday, July 11, 2012 3:21 PM
      > To: json@yahoogroups.com
      > Subject: Re: [json] Re: Looking for help with syntax error
      >
      > ugg.. the dreaded punt! lol
      >
      > I've searched StackOverflow, but I'll post the question over there too.
      >
      > If anyone happens across this thread though and has any other ideas,
      > please, feel free to offer them up, either here or via email.
      >
      > Thanks for all your suggestions.
      >
      > Tim
      >
      > ________________________________
      > From: Andrew Faulds <ajfweb@... <mailto:ajfweb%40googlemail.com>
      > >
      > To: json@yahoogroups.com <mailto:json%40yahoogroups.com>
      > Sent: Wednesday, July 11, 2012 4:05 PM
      > Subject: Re: [json] Re: Looking for help with syntax error
      >
      > I don't think this is really a JSON issue, more a browser issue, so I'd
      > suggest going to StackOverflow instead.
      >
      > On 11 July 2012 21:43, Reaus@... <mailto:Reaus%40yahoo.com> <
      > reaus@... <mailto:reaus%40yahoo.com> > wrote:
      >
      > > **
      > >
      > >
      > > Well.. that makes sense. But then why would it work when sitting on one
      > > server, and not on the other?
      > >
      > > It's the same code (I've double and triple checked), and the same browser
      > > (i'm using IE8 from my laptop to point to both the dev server and the QA
      > > server), so my logical (at least in my mind) assumption was that it had
      > to
      > > be some sort security setting on the Windows 2008 server. I could be
      > > wrong, but that was just what it seemed like to me.
      > >
      > > Believe me, I would glad to be wrong about this if I can figure out a
      > > fix! :)
      > >
      > > Tim
      > >
      > > ________________________________
      > > From: Jos de Jong <wjosdejong@... <mailto:wjosdejong%40gmail.com>
      > >
      > > To: Gil <reaus@... <mailto:reaus%40yahoo.com> >
      > > Sent: Wednesday, July 11, 2012 3:29 PM
      > > Subject: Re: Looking for help with syntax error
      > >
      > >
      > > Why do you think the problem has to do with the server? "JSON not
      > > declared" is a client side issue. And if the responseText is correct (and
      > > you tested it as being valid JSON), the side apparently works fine, and
      > the
      > > problem should be located client side, right?
      > >
      > > On Wed, Jul 11, 2012 at 9:14 PM, Gil <reaus@... <mailto:
      > reaus%40yahoo.com> > wrote:
      > >
      > > >Hi, Thanks for the tips, but I've already done this.
      > > >
      > > >I've looked at the return value from both environments and they're
      > > identical. So since it's valid data in one instance, it should be valid
      > in
      > > the other.
      > > >
      > > >And I know that my browser supports JSON, since as I've stated, it works
      > > in my browser if pointed to my development server, but not if pointed to
      > > the QA server.
      > > >
      > > >I keep going back to the idea that it must be some security setting on
      > > the 2008 servers, possibly with the http_request call, since both errors
      > > happen on a line with the http_request in it. The QA servers are in a
      > farm,
      > > but I get the same syntax errors whether I go through the load balancer
      > or
      > > hit the server directly.
      > > >
      > > >Thanks for your help.
      > >
      > > >
      > > >
      > > >
      > > >--- In json@yahoogroups.com <mailto:json%40yahoogroups.com> , Jos de
      > Jong <wjosdejong@...> wrote:
      > > >>
      > > >> To figure out what is going wrong, just do some debugging of your
      > > >> application - nothing special JSON related...
      > > >>
      > > >> - inspect the contents of http_request.responseText, to verify if this
      > > is
      > > >> indeed valid JSON data. You can put a debug point (if your browser
      > > supports
      > > >> that), or output the response via
      > > console.log(http_request.responseText).
      > > >> - test if your browser supports JSON, just do some tests in your
      > > browsers
      > > >> console, see if JSON.parse('{"J":5,"0":"N"}') works for example
      > > >>
      > > >>
      > > >> On Wed, Jul 11, 2012 at 8:07 PM, Reaus@... <reaus@...> wrote:
      > > >>
      > > >> > **
      > > >
      > > >> >
      > > >> >
      > > >> > I'm trying to implement a JSON call to simulate AJAX on a certain
      > page
      > > >> > where an AJAX panel isn't a viable option.
      > > >> >
      > > >> > I want call my .aspx page when a State is selected from a drop down
      > > and
      > > >> > populate the Counties drop down.
      > > >> >
      > > >> > in my State dropdown, I have this call:
      > > >> >
      > > >> > onchange="jsonDropDownLoader('COUNTIES', this,
      > > 'Content2_DDLCounties')"
      > > >> >
      > > >> > That call is on the page and the code is here:
      > > >> >
      > > >> > function jsonDropDownLoader(sType, oParent, oChild) {
      > > >> > var lstrChild = document.getElementById(oChild);
      > > >> > var lstrFilter = ""
      > > >> >
      > > >> > if (oParent.value > "") {
      > > >> > lstrFilter = oParent.value
      > > >> > }
      > > >> >
      > > >> > lstrChild.options.length = 0;
      > > >> > if (oParent.value > "") {
      > > >> > var JSONobject = {};
      > > >> > var http_request = new XMLHttpRequest();
      > > >> > url = "/AltairWeb.NET/RS/jsonDropDownLoader.aspx?TYPE=" +
      > > sType +
      > > >> > "&FILTER=" + lstrFilter
      > > >> > http_request.open("GET", url, false);
      > > >> > http_request.onreadystatechange = function () {
      > > >> > var done = 4, ok = 200;
      > > >> > if (http_request.readyState == done &&
      > > http_request.status ==
      > > >> > ok) {
      > > >> > JSONobject = JSON.parse(http_request.responseText);
      > > >> > }
      > > >> > };
      > > >> > http_request.send(null);
      > > >> > var JSONarray = eval('(' + http_request.responseText +
      > > ')').data
      > > >> > for (var i = 0; i < JSONarray.length; ++i) {
      > > >> > var optn = document.createElement("OPTION");
      > > >> > optn.text = JSONarray[i].text;
      > > >> > optn.value = JSONarray[i].value;
      > > >> > lstrChild.options.add(optn);
      > > >> > }
      > > >> > }
      > > >> > }
      > > >> >
      > > >> > It returns a string which I then use to populate the County drop
      > down.
      > > >> >
      > > >> > I'm getting data back, but it's not rendering on your QA server.
      > > Using the
      > > >> > developer tools with IE8, I can see that I have a error on this
      > line:
      > > >> >
      > > >> > JSONobject = JSON.parse(http_request.responseText);
      > > >> > it says that JSON is not declared.
      > > >> >
      > > >> > It says I also have a syntax error on this line:
      > > >> >
      > > >> > var JSONarray = eval('(' + http_request.responseText + ')').data
      > > >> >
      > > >> > This works perfectly on my development box. However, my development
      > > box
      > > >> > has WinXP / IIS 5 on it, whereas, our QA server is a Win2008 server
      > > with
      > > >> > IIS7.5. We have new development boxes coming, but until then, I'm
      > > stuck
      > > >> > with the XP machine.
      > > >> >
      > > >> > Since it works locally, it seems like it must be a security issue
      > with
      > > >> > either Windows or IIS on the QA server, possibly with the
      > http_request
      > > >> > call, but I can't find anything via google that has helped me figure
      > > this
      > > >> > out.
      > > >> >
      > > >> > Any ideas?
      > > >> >
      > > >> > Thanks in advance!
      > > >> > Tim
      > > >> >
      > > >> > [Non-text portions of this message have been removed]
      > > >> >
      > > >> >
      > > >> >
      > > >>
      > > >>
      > > >> [Non-text portions of this message have been removed]
      > > >>
      > > >
      > > >
      > > >
      > >
      > > [Non-text portions of this message have been removed]
      > >
      > >
      > >
      >
      > --
      > Andrew Faulds (AJF)
      > http://ajf.me/
      >
      > [Non-text portions of this message have been removed]
      >
      > [Non-text portions of this message have been removed]
      >
      > [Non-text portions of this message have been removed]
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >



      --
      Andrew Faulds (AJF)
      http://ajf.me/


      [Non-text portions of this message have been removed]
    • Reaus@yahoo.com
      That was probably just a type when I copied it to the group. I did finally figure out what the problem was. It was basically an id10t error. I knew it was
      Message 2 of 12 , Jul 12, 2012
      • 0 Attachment
        That was probably just a type when I copied it to the group.


        I did finally figure out what the problem was. It was basically an id10t error. I knew it was going to turn out to be something incredibly stupid that I was overlooking.


        The IIS directory structure is different locally than on the actual web servers. Locally, our url is http://localhost/AltairWeb.Net/%c2%a0%c2%a0 But on the web servers it would be http://qa.altair.org/%c2%a0 So the actual AltairWeb.Net folder is replaced by qa.altair.org.  That's why when I hit the codebehind page directly, it returned records, but the javascript/json call threw an error... the json call was actually throwing a page not found error on the http_request.responseText statement. It being called a syntax error threw me and had me thinking that structurally, it was written incorrectly.


        once I changed:

        url ="/AltairWeb.NET/RS/jsonDropDownLoader.aspx?TYPE="+sType +"&FILTER="+lstrFilter

        to

        url ="/RS/jsonDropDownLoader.aspx?TYPE="+sType +"&FILTER="+lstrFilter

        It began working perfectly on the QA servers.


        I do thank everyone here for all their help and suggestions.


        This is the first time I've attempted to use json, but I really like it and it won't be the last time. This group is a great resource and I'll definitely be lurking and trying to learn what I can about json.

        Thanks again!

        Tim



        ________________________________
        From: Andrew Faulds <ajfweb@...>
        To: json@yahoogroups.com
        Sent: Wednesday, July 11, 2012 5:52 PM
        Subject: Re: [json] Re: Looking for help with syntax error


         
        You might want to JSLint your code, looks like there's some missing
        semicolons in there, and JSLint might spot what we haven't.

        On 11 July 2012 23:41, Reaus@... <reaus@...> wrote:

        > **
        >
        >
        >
        >
        > I didn't think so, but I went ahead and put the
        >
        > <meta http-equiv="X-UA-Compatible" content="IE=8" />
        > tag into my master page and tested it. I did a view source first and
        > verified that the meta tag was there, but I get the same 2 js syntax errors.
        >
        > So frustrating!
        >
        > Thanks for the tip though!
        >
        > ________________________________
        > From: Mark Ingalls <mark_ingalls@...>
        > To: json@yahoogroups.com
        > Sent: Wednesday, July 11, 2012 4:57 PM
        > Subject: RE: [json] Re: Looking for help with syntax error
        >
        >
        >
        >
        > Just a stab in the dark here, but could the response from the QA server be
        > putting your browser into IE 7 mode?
        >
        >
        > http://stackoverflow.com/questions/4715373/json-not-defined-internet-explorer-8
        >
        > From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of
        > Reaus@...
        > Sent: Wednesday, July 11, 2012 3:21 PM
        > To: json@yahoogroups.com
        > Subject: Re: [json] Re: Looking for help with syntax error
        >
        > ugg.. the dreaded punt! lol
        >
        > I've searched StackOverflow, but I'll post the question over there too.
        >
        > If anyone happens across this thread though and has any other ideas,
        > please, feel free to offer them up, either here or via email.
        >
        > Thanks for all your suggestions.
        >
        > Tim
        >
        > ________________________________
        > From: Andrew Faulds <ajfweb@... <mailto:ajfweb%40googlemail.com>
        > >
        > To: json@yahoogroups.com <mailto:json%40yahoogroups.com>
        > Sent: Wednesday, July 11, 2012 4:05 PM
        > Subject: Re: [json] Re: Looking for help with syntax error
        >
        > I don't think this is really a JSON issue, more a browser issue, so I'd
        > suggest going to StackOverflow instead.
        >
        > On 11 July 2012 21:43, Reaus@... <mailto:Reaus%40yahoo.com> <
        > reaus@... <mailto:reaus%40yahoo.com> > wrote:
        >
        > > **
        > >
        > >
        > > Well.. that makes sense. But then why would it work when sitting on one
        > > server, and not on the other?
        > >
        > > It's the same code (I've double and triple checked), and the same browser
        > > (i'm using IE8 from my laptop to point to both the dev server and the QA
        > > server), so my logical (at least in my mind) assumption was that it had
        > to
        > > be some sort security setting on the Windows 2008 server. I could be
        > > wrong, but that was just what it seemed like to me.
        > >
        > > Believe me, I would glad to be wrong about this if I can figure out a
        > > fix! :)
        > >
        > > Tim
        > >
        > > ________________________________
        > > From: Jos de Jong <wjosdejong@... <mailto:wjosdejong%40gmail.com>
        > >
        > > To: Gil <reaus@... <mailto:reaus%40yahoo.com> >
        > > Sent: Wednesday, July 11, 2012 3:29 PM
        > > Subject: Re: Looking for help with syntax error
        > >
        > >
        > > Why do you think the problem has to do with the server? "JSON not
        > > declared" is a client side issue. And if the responseText is correct (and
        > > you tested it as being valid JSON), the side apparently works fine, and
        > the
        > > problem should be located client side, right?
        > >
        > > On Wed, Jul 11, 2012 at 9:14 PM, Gil <reaus@... <mailto:
        > reaus%40yahoo.com> > wrote:
        > >
        > > >Hi, Thanks for the tips, but I've already done this.
        > > >
        > > >I've looked at the return value from both environments and they're
        > > identical. So since it's valid data in one instance, it should be valid
        > in
        > > the other.
        > > >
        > > >And I know that my browser supports JSON, since as I've stated, it works
        > > in my browser if pointed to my development server, but not if pointed to
        > > the QA server.
        > > >
        > > >I keep going back to the idea that it must be some security setting on
        > > the 2008 servers, possibly with the http_request call, since both errors
        > > happen on a line with the http_request in it. The QA servers are in a
        > farm,
        > > but I get the same syntax errors whether I go through the load balancer
        > or
        > > hit the server directly.
        > > >
        > > >Thanks for your help.
        > >
        > > >
        > > >
        > > >
        > > >--- In json@yahoogroups.com <mailto:json%40yahoogroups.com> , Jos de
        > Jong <wjosdejong@...> wrote:
        > > >>
        > > >> To figure out what is going wrong, just do some debugging of your
        > > >> application - nothing special JSON related...
        > > >>
        > > >> - inspect the contents of http_request.responseText, to verify if this
        > > is
        > > >> indeed valid JSON data. You can put a debug point (if your browser
        > > supports
        > > >> that), or output the response via
        > > console.log(http_request.responseText).
        > > >> - test if your browser supports JSON, just do some tests in your
        > > browsers
        > > >> console, see if JSON.parse('{"J":5,"0":"N"}') works for example
        > > >>
        > > >>
        > > >> On Wed, Jul 11, 2012 at 8:07 PM, Reaus@... <reaus@...> wrote:
        > > >>
        > > >> > **
        > > >
        > > >> >
        > > >> >
        > > >> > I'm trying to implement a JSON call to simulate AJAX on a certain
        > page
        > > >> > where an AJAX panel isn't a viable option.
        > > >> >
        > > >> > I want call my .aspx page when a State is selected from a drop down
        > > and
        > > >> > populate the Counties drop down.
        > > >> >
        > > >> > in my State dropdown, I have this call:
        > > >> >
        > > >> > onchange="jsonDropDownLoader('COUNTIES', this,
        > > 'Content2_DDLCounties')"
        > > >> >
        > > >> > That call is on the page and the code is here:
        > > >> >
        > > >> > function jsonDropDownLoader(sType, oParent, oChild) {
        > > >> > var lstrChild = document.getElementById(oChild);
        > > >> > var lstrFilter = ""
        > > >> >
        > > >> > if (oParent.value > "") {
        > > >> > lstrFilter = oParent.value
        > > >> > }
        > > >> >
        > > >> > lstrChild.options.length = 0;
        > > >> > if (oParent.value > "") {
        > > >> > var JSONobject = {};
        > > >> > var http_request = new XMLHttpRequest();
        > > >> > url = "/AltairWeb.NET/RS/jsonDropDownLoader.aspx?TYPE=" +
        > > sType +
        > > >> > "&FILTER=" + lstrFilter
        > > >> > http_request.open("GET", url, false);
        > > >> > http_request.onreadystatechange = function () {
        > > >> > var done = 4, ok = 200;
        > > >> > if (http_request.readyState == done &&
        > > http_request.status ==
        > > >> > ok) {
        > > >> > JSONobject = JSON.parse(http_request.responseText);
        > > >> > }
        > > >> > };
        > > >> > http_request.send(null);
        > > >> > var JSONarray = eval('(' + http_request.responseText +
        > > ')').data
        > > >> > for (var i = 0; i < JSONarray.length; ++i) {
        > > >> > var optn = document.createElement("OPTION");
        > > >> > optn.text = JSONarray[i].text;
        > > >> > optn.value = JSONarray[i].value;
        > > >> > lstrChild.options.add(optn);
        > > >> > }
        > > >> > }
        > > >> > }
        > > >> >
        > > >> > It returns a string which I then use to populate the County drop
        > down.
        > > >> >
        > > >> > I'm getting data back, but it's not rendering on your QA server.
        > > Using the
        > > >> > developer tools with IE8, I can see that I have a error on this
        > line:
        > > >> >
        > > >> > JSONobject = JSON.parse(http_request.responseText);
        > > >> > it says that JSON is not declared.
        > > >> >
        > > >> > It says I also have a syntax error on this line:
        > > >> >
        > > >> > var JSONarray = eval('(' + http_request.responseText + ')').data
        > > >> >
        > > >> > This works perfectly on my development box. However, my development
        > > box
        > > >> > has WinXP / IIS 5 on it, whereas, our QA server is a Win2008 server
        > > with
        > > >> > IIS7.5. We have new development boxes coming, but until then, I'm
        > > stuck
        > > >> > with the XP machine.
        > > >> >
        > > >> > Since it works locally, it seems like it must be a security issue
        > with
        > > >> > either Windows or IIS on the QA server, possibly with the
        > http_request
        > > >> > call, but I can't find anything via google that has helped me figure
        > > this
        > > >> > out.
        > > >> >
        > > >> > Any ideas?
        > > >> >
        > > >> > Thanks in advance!
        > > >> > Tim
        > > >> >
        > > >> > [Non-text portions of this message have been removed]
        > > >> >
        > > >> >
        > > >> >
        > > >>
        > > >>
        > > >> [Non-text portions of this message have been removed]
        > > >>
        > > >
        > > >
        > > >
        > >
        > > [Non-text portions of this message have been removed]
        > >
        > >
        > >
        >
        > --
        > Andrew Faulds (AJF)
        > http://ajf.me/
        >
        > [Non-text portions of this message have been removed]
        >
        > [Non-text portions of this message have been removed]
        >
        > [Non-text portions of this message have been removed]
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >

        --
        Andrew Faulds (AJF)
        http://ajf.me/

        [Non-text portions of this message have been removed]




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