Hello there, I want to display stock price on my website for the company for instance YHOO. what I need to do? I would like to mention that I only understand html and css so I would highly appreciate if someone properly guide me considering my skill set (not just by using programming names, jargons etc ). Obviously I understand there might be another language involved therefore a proper direction and guidance would be appreciated. regards
Hi there, One way to do this would be to use a Stock Data api, one such is googles the url below http://www.google.com/finance/info?infotype=infoquoteall&q=GOOG&callback=? Returns JSONP which is "JSON with padding" a workaround for cross domain scripting rule. I written an example of its usage in JQuery $(document).ready(function() { $.ajax({ url: 'http://www.google.com/finance/info?infotype=infoquoteall&q=GOOG&callback=?', jsonpCallback: 'jsonCallback', contentType: "application/json", dataType: 'jsonp', async:false, success: function(json) { $('#result').html(json[0].name+' - '+json[0].l); }, error: function(e) { console.log(e.message); } }); }); Code (markup): This requres the JQuery library found here (http://jquery.com/) and a working example (http://jsfiddle.net/B2HL8/4/) Hope this helps
Perfect! thats called proper guidance. with fiddle link. Thanks bro One more thing there are some Stocks that do not show up. like LRDR, ASKE when I replace GOOG with any of these. what do I need to do for that?
From what i can tell they are not present on googles financial data. I Checked yahoo for the ones you provided and they are both present there i updated the fiddle with a way to do it. http://jsfiddle.net/B2HL8/7/ however it requires the use of yahoo query builder. developer.yahoo.com/yql/console
I think Yahoo also has an API as well that you can use. If you eventually want to display real-time stock prices you can purchase a license from http://www.xignite.com/
Thank you so much for your reply. sorry for late response. The fiddle you shared this time shows loads of information not sure if that's a glitch or what but as the fiddle link you shared above that showed just google price is perfect and something I am looking for. but the stock in this case is LRDR I checked on google stock it showed me LRDR information https://www.google.co.uk/finance?q=lrdr&ei=zAdFU4DwLqmEwAOGvwE Could we use it the way you used/displayed Google stock. Your help would be highly appreciated.
Not a glitch, it's simply to show everything that is sent back to you which is a lot more info than just a stock price. I was able to retrieve the price using q='OTCMKTS%3ALRDR' http://jsfiddle.net/B2HL8/9/ Note %3A is a urlencoded :
Thanks for your quick reply. Thanks for your quick reply. I am naive in this area so thought may be that is a glitch lol sorry about that. Sorry for being pain again. Could you also tell me please how to hide other stock info. I am basically just interested in Stock price like initially you displayed Google's price