Using jquery, i obtain some data from .json file and a want alert this data after click on the div tag, how make this ?
this is an approximate example, what i want?
Code:
$.getJSON("mydata.json").success ( function (myJson) {
myVariable = myJson["Positions"][0]["x"];
}
);
function muClick () {
alert(myVariable );
}
<body>
<div onclick="muClick();"> text text text </div>
You shouldn't really care how the data looks in the alert since you will be the only one to see it - since alert is a debugging command that should be removed before your script goes live - since you will not want people using the checkbox in the alert that turns off JavaScript or all the subsequent alerts (depending on which browser they are using).