I have a some data in JSON format(which comes from php) to b开发者_StackOverflow中文版e passed to a javascript function. I'm getting 'invalid property id' error when I try to do this.
Error: invalid property id
Source File: http://localhost/MathVoyager/index.php/test
Line: 1, Column: 15
Source Code:
draw_quadratic({
Below is the js function signature(both data and options are in JSON format)
function draw_quadratic(data, options, alpha, beta)
Below is a sample function call.
draw_quadratic({"label":"(((1)*x^((1))+(4))*((1)*x^((1))+(6))) = (0)","data":[[-8,8],[-7.5,5.25],[-7,3],[-6.5,1.25],[-6,0],[-5.5,-0.75],[-5,-1],[-4.5,-0.75],[-4,0],[-3.5,1.25],[-3,3],[-2.5,5.25],[-2,8]],"xaxis":1,"yaxis":1}, {"series":{"points":{"show":true},"lines":{"show":true}},"grid":{"hoverable":true,"clickable":true}}, 4, 8);
(I'm trying to plot some graph using flot js library)
Thanks in advance
mydata= JSON.parse('{"label":"(((1)*x^((1))+(4))*((1)*x^((1))+(6))) = (0)","data":[[-8,8],[-7.5,5.25],[-7,3],[-6.5,1.25],[-6,0],[-5.5,-0.75],[-5,-1],[-4.5,-0.75],[-4,0],[-3.5,1.25],[-3,3],[-2.5,5.25],[-2,8]],"xaxis":1,"yaxis":1}');
myoptions= JSON.parse('{"series":{"points":{"show":true},"lines":{"show":true}},"grid":{"hoverable":true,"clickable":true}}');
draw_quadratic( mydata,myoptions,4,8);
Don't forget ''
or ""
when sending parameters to jsonparse it takes a string
- www.JSON.org/json2.js
- www.JSON.org/js.html
In php you can use:
- .json_decode — Decodes a JSON string
- .json_encode — Returns the JSON representation of a value
The code I wrote works with me in Chrome.
精彩评论