Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-09-2012, 09:49 PM   PM User | #1
dadli88
New Coder

 
Join Date: May 2012
Posts: 16
Thanks: 4
Thanked 0 Times in 0 Posts
dadli88 is an unknown quantity at this point
Obtain and using data, from .json file

Hello

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>
Please help me
dadli88 is offline   Reply With Quote
Old 05-09-2012, 10:07 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,530
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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).
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:06 AM.


Advertisement
Log in to turn off these ads.