JSFiddle - React, Tailwind, and code Playground
by kritzikratzi
HTML
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<div onClick="loadBarometerData()"> Click Me</div><!--I can't get this to work-->
<div onClick="showPrice({symbol: 'IBM', price: 91.42})">Click Me Too</div>
JavaScript
function loadBarometerData(){
// 1. it's not generally bad practice to put stuff in the
// onClick listeners, but really... don't put such long code there! it's not readable ...
// 2. you were missing a "http://" and it was downloading
// jsfiddle.net/pipes.yahoo.com/....
// 3. getJSON doesn't return a result immediately, you need to use callbacks for that!!
$.getJSON('http://pipes.yahoo.com/pipes/pipe.run?_id=467a55b506ba06b9ca364b1403880b65&_render=json&textinput1=40.78158&textinput2=-73.96648&_callback=?' ).success( barometer );
};
function barometer(data) {
console.log( data );
// 4. you had items instead of items[0]
// similar with data.
alert(data.value.items[0].data[1].parameters.pressure.value);
};
function showPrice(data) {
alert("Symbol: " + data.symbol[0] + ", Price: " + data.price);
}