-3

I have the below fiddle which seems to work fine:

 jQuery(function() {

     // Remove any double class applications
     jQuery(".pricedisplay .pricedisplay").removeClass("pricedisplay");

     // Load from BitPay's conversion rates JSON page
     jQuery.ajax({
       dataType: "json",
       url: "https://bitpay.com/api/rates",
       success: function(data) {

http://jsfiddle.net/cox6p7br/

However when I try this code live, it's not working.

Please any help is appreciated.

Sparky
  • 98,165
  • 25
  • 199
  • 285
stebe
  • 1
  • 4

1 Answers1

0

Yyou'll want to ensure that you are also properly reference jQuery using a <script> tag that either explicitly points to a local file or a CDN that is hosting the library :

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
     <!-- Your jQuery Code Here -->
</script>

If you are still encountering issues and you are using a local file, then it's likely a problem with how you are referencing the file itself. You can use the Developer Tools (F12) within your browser and take a look at the Console section, which should indicate any issues with loading your file (via a 404 error).

Rion Williams
  • 74,820
  • 37
  • 200
  • 327
  • Thank you so much!! This solved it! Legend! – stebe Apr 11 '16 at 20:20
  • One last question, if I wanted to add a percentage to the final value of the BTC on display - how would I go about this? – stebe Apr 11 '16 at 20:24
  • I'm not sure exactly where you are referring to. If it's the decimal value that appears before "BTC", then you could add it on the line that you set the `text` property via `text: "" + (num / data[member].rate).toFixed(4) + "% BTC*"` as seen [here](http://jsfiddle.net/cox6p7br/2/). – Rion Williams Apr 11 '16 at 20:25
  • Sorry what I meant was for example add 10% extra to the value of the BTC – stebe Apr 11 '16 at 20:32
  • Ah. Just multiply your calculate by 1.1 : `text: "" + ((num / data[member].rate) * 1.1).toFixed(4) + "% BTC*"` – Rion Williams Apr 11 '16 at 20:35
  • Brilliant, thanks for your time mate – stebe Apr 11 '16 at 20:40
  • *"it doesn't currently have a reference to the jQuery library, which you need to add using the External Resources tab on the left"* ~ This is wrong. [Click on the gear icon in the "JavaScript" pane and you'll see that jQuery was already properly included in the "Frameworks & Extensions" section](http://jsfiddle.net/cox6p7br/). So in [your version of the jsFiddle](http://jsfiddle.net/cox6p7br/1/), jQuery is included twice. – Sparky Apr 11 '16 at 21:00
  • @Sparky Thanks for that. I generally prefer [JSBin](http://www.jsbin.com) to JSFiddle, so it's been quite a while since I've used it. I'll chalk it up to that. – Rion Williams Apr 11 '16 at 21:03
  • I've removed that section of the response as it really wasn't relevant to the actual issue. Thanks again @Sparky – Rion Williams Apr 11 '16 at 21:16