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

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

Expand Messages
  • Andrew Faulds
    Jul 11, 2012
    • 0 Attachment
      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@... <reaus@...> 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@...>
      > To: Gil <reaus@...>
      > 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@...> 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, 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]
    • Show all 12 messages in this topic