DeeJay Posted October 23, 2013 Report Share Posted October 23, 2013 Hi, I am getting some data from excel worksheet; converting to json; then saving it as a hiddenfield value. On client side, I am getting the value of the hiddenfield and passing to jchartfx. I seem to have an error everytime I do this. If I take the data out of the hiddenfield and write it out as a string in the jquery code, it works just fine. var PriceData = $('#hidPriceChart').val(); // does not work // the following works if I take the value from hidPRiceChart and set it manually. var PriceData = [{ "Commodity": "CPO MDEX FUTURES", "MKT_Price": 1009.3500780459954 }, { "Commodity": "CPO MAL Physicals", "MKT_Price": 975.99999999999989 }, { "Commodity": "ROL MAL Physicals", "MKT_Price": 1008.7500000000001 }, { "Commodity": "SB CBOT Call", "MKT_Price": 24.020566370720026 }, { "Commodity": "SBM CBOT FUTURES", "MKT_Price": 526.8994283471892 }, { "Commodity": "SBO CBOT FUTURES", "MKT_Price": 1177.092511013223 }, { "Commodity": "CRUDE NYMEX Put", "MKT_Price": 45.37689167750014 }, { "Commodity": "HO NYMEX FUTURES", "MKT_Price": 860.37383177569916 }, { "Commodity": "GO ICE FUTURES", "MKT_Price": 874 }]; chart1.setDataSource(PriceData); // it fails at this line. Can anyone tell me what I am doing wrong? TestChartFXLayoutError.zip Quote Link to comment Share on other sites More sharing options...
0 JuanC Posted October 23, 2013 Report Share Posted October 23, 2013 I suspect when you do PriceData = $("#hidPriceChart").val() you might be getting a string instead of an array of javascript objects, if this is so, you might need to use eval() to get the data as an array of objects. Note that when you manually hardcode var priceData = [{..}], the priceData variable will hold an array of objects so if you do alert(priceData) javascript should tell you object or array or something like that as opossed to a string. Another option would be to change your ASP.NET code so that it generates the client code that declares var priceData=[{... instead of using a hidden field. Regards, JuanC Quote Link to comment Share on other sites More sharing options...
0 DeeJay Posted October 23, 2013 Author Report Share Posted October 23, 2013 Juan C; you are the Man! I used eval() and it works perfectly now. Thank you ever so much. DeeJay. Quote Link to comment Share on other sites More sharing options...
Question
DeeJay
Hi,
I am getting some data from excel worksheet; converting to json; then saving it as a hiddenfield value.
On client side, I am getting the value of the hiddenfield and passing to jchartfx.
I seem to have an error everytime I do this.
If I take the data out of the hiddenfield and write it out as a string in the jquery code, it works just fine.
var PriceData = $('#hidPriceChart').val(); // does not work
Can anyone tell me what I am doing wrong?
TestChartFXLayoutError.zip
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.