javascript - JSON syntax error on Windows 2008 -


I'm trying to implement a JSON call to simulate AJAX on a certain page where an AJAX panel is a Not a viable option.

When a state is selected from the drop down and the county falls into the drop down, I want to call my .aspx page.

In my state dropdown, I have this call:

onchange = "jsonDropDownLoader ('COUNTIES', this, 'Content2_DDLCounties')"

This call Page and code is here:

  function jsonDropDownLoader (sType, oParent, oChild) {var lstrChild = document.getElementById (oChild); Var lstrFilter = "" if (operant.value> "") {lstrfilter = oParent.value} lstrChild.options.length = 0; If (operant.value> "") {var JSONobject = {}; Var http_request = new XMLHttpRequest (); Url = "/AltairWeb.NET/RS/jsonDropDownLoader.aspx?type=" + sType + "and FILTER =" + lstrfilter http_request.open ("GET", url, incorrect); Http_request.onreadystatechange = function () {var done = 4, ok = 200; If (http_request.readyState == did & amp; http_request.status == OK) {JSONobject = JSON.parse (http_request.responseText); }}; Http_request.send (zero); Var JSONarray = eval ('(' + http_request.responsetext + ')). Data for (var i = 0; i   

This is a string that I then use to populate the County drop down.

I'm getting data back, but it's your QA server. Using Developer Tools with IE8, I can see that I have an error on this line:

  JSONobject = JSON.parse (http_request.responseText);   

It indicates that JSON has not been declared.

It says that I also have a syntax error on this line:

  var JSONarray = Eval ('(' + http_request.responsetext + ')'). Data   

This works perfectly on my development box. However, in my development box it is WinXP / IIS 5, while our QA server is a Win2008 server with IIS7.5. We have new development boxes coming up, but by then, I have stayed with the XP machine.

Since it works locally, it seems that there should be a security problem with either Windows or IIS on the QA server, possibly with http_request calls, but I do not have anything via Google Is not getting, which has helped me figure it out.

I know that I have seen the post JSN. PRAE is not supported by IE before IE9. , But it works perfectly on my IE server, when I point to my dev server, but when I do not point to QA server, it is not a browser problem. Any ideas?

JSON.parse () is the function of your browser, not a server

You is surely the difference server ... and your client is not the browser

Maybe you might want to consider using something like jQuery (which makes your coding easier , And thus can help in arbitrating cross-browser problems). For example:

  • var json = '{"result": true, "count": 1}', obj = JSON & amp; Amp; JSN Parse (JSNO) || $ .fromSON (JSN);

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -