I want insert into variable1 that value -0.6200
and the variable2 = 3333
How can I do that?
I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy
If I am reading you right, json.result is itself another JSON with two items and you want to parse it, right?
If so you just need to call JSON.parse on the result you have to recursively parse the next level and then use the dot notation “.” to access the fields:
var parsedResult = JSON.parse(json.result);
document.getElementById("FirstDataId").value = parsedResult.data1;
document.getElementById("SecondDataId").value = parsedResult.data2;
But I can see only first and second, without json data
first
second
I've edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy
I just picked the names for the HTML fields “FirstDataId” and “SecondDataId” out of the air at random–you should use the names of fields you have defined in the HTML part of your web page.
If you use the Javascript debugger in your browser, you should be able to tell if parsedResult has the right value–what you are doing should be correct.
You can have a look at my JSON tutorial for publishing too:
Maybe you could show us a screen shot of the error–it is not clear what is undefined here and I think it must be something else besides the JSON we are working on here.
Yes my code copies the values to a variable in javascript, the problem is that I can not use them separately in a variable date1 and date2 in another variable