Problems in your code
- You forget to include
http://
in your link
You need to try this (see alert
. It will alert the title)
<div onClick="$.getJSON('http://pipes.yahoo.com/pipes/pipe.run?_id=467a55b506ba06b9ca364b1403880b65&_render=json&textinput1=40.78158&textinput2=-73.96648&_callback=?', function(data){alert(data.value.title)})">Click Me</div><!--I can't get this to work-->
DEMO
But its better to use like following:
<div class="loadjson">Click Me</div>
function barometer() {
$.getJSON('http://pipes.yahoo.com/pipes/pipe.run?_id=467a55b506ba06b9ca364b1403880b65&_render=json&textinput1=40.78158&textinput2=-73.96648&_callback=?', function(data) {
alert(data.value.title);
})
}
$('div.loadjson').on('click', function() {
barometer();
});
Note: $.getJSON()
returns two parameters
within data
object.
- 1st one is `count` that have integer value
- 2nd one is `value`, which is an `Object`.
To get the second parameter you need to use data.value
.
DEMO