OZONE Asylum
Forums
DHTML/Javascript
JSON eval() problems with IE
This page's ID:
29265
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I'm trying to load a Yahoo widget DataTable by using some JSON data that I have created myself dynamically. I can get the DataTable to load and the example works in Firefox, but it won't work in IE. When I load the page, the DataTable says "Loading Data...", and I get an error within the browser line 773: 'undefined' is null or not an object note: the code does not exceed line 140 The code is appended: [code] <script type="text/javascript"> var sample_input_data = "0.0,1.0:1.0,21.0:2.0,321.0:3.0,2005.0:4.0,7737.0:5.0,22461.0:6.0,54121.0:7.0,114381.0:8.0,219345.0:9.0,390277.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:10.0,654321.0:"; var myColumnHeaders = [ {key:"areacode",className:"col1"}, {key:"state",className:"col2"}]; var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders); var myDataSource2 = new YAHOO.util.DataSource(formatStringToJSON(sample_input_data)); myDataSource2.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; myDataSource2.responseSchema = { fields: ["areacode","state"] }; var myDataTable = new YAHOO.widget.DataTable("scroll",myColumnSet,myDataSource2,{scrollable:true}); function formatStringToJSON(inputString) { var point_sets = inputString.split(":"); var json_text = ""; for (x = 0; x < point_sets.length-1; x++) { var point = point_sets[x].split(","); json_text += "{ x: " + point[0] + ", y: " + point[1] + "}, "; } json_text = '( [' + json_text + '] )'; //var data_points = eval ( ' { points: [' + json_text + '] }'); var data_points = eval( '{ areacodes: [ { areacode: \"201\", state: \"New Jersey\"}, ] }' ); return data_points; } </script> [/code] I originally populated the DataTable using a static structure, but now I need to populate it dynamically so I'm doing this using a string and using eval(). Does anyone have an idea why it won't work in IE. Or is there another way of doing this?
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »