Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Netrunner21
@Netrunner21
mine*
Johnny
@jtan3
@Riley1435 if you go to your developer tools and console you'll see an error
@Riley1435 Ctrl + Shift + J
@Riley1435 to open console
Netrunner21
@Netrunner21
@jtan3 good catch
@Riley1435 add ?callback=? to the end of your url
its either a workaround for APIs that restrict access, or it helps codepen in some way. I'm not sure.
Riley
@Riley1435
okay yeah the api has a cross origin error
now it says undefined. im thinking data.temperature is not calling the right object in the JSON data
Netrunner21
@Netrunner21
Mine was data.currently.temperature
there's an extra step in the object notation to index
Riley
@Riley1435
I tired that earlier and i figured it didnt work
but now it should work since the problem was the url
thanks for the help
makes sense after opening the link and viewing the data again
Netrunner21
@Netrunner21
no problem
leomartin
@abhirupleo
Can someone help me with the random quote generator
app?
Johnny
@jtan3
@abhirupleo ask away
leomartin
@abhirupleo
So here is my js code

function generatecolor(){
var color=['#27303B','#F67858','#1182C7','#EC9A4E','#8666F2','#97E59A',''];
var random= Math.floor(Math.random()*color.length);
$("html body").animate({backgroundColor:color[random]}, 1200);
}

function getquote(){
$.ajax({

                    headers: {
                              "X-Mashape-Key": "HL5Yr3E9RZmshc7CyNeA0JrwnjD7p1H6dKVjsnDjlYdeqTgBW9",
                              Accept: "application/json",
                              "Content-Type": "application/x-www-form-urlencoded"
                            },
                        url: 'https://andruxnet-random-famous-quotes.p.mashape.com/cat=',
                        success: function(r){
                        if(typeof(r)=='String'){
                            r=JSON.parse(r);
                            console.log('hey');
                            console.log(r.quote);
                            $("#text").text(r.quote);
                        }
                    }
            });

}

$(document).ready(function() {
$('body').animate({backgroundColor:'#02CE9C'}, 1200);
$('.getquote').on('click', function(event) {
generatecolor();
getquote();
/ Act on the event /
});
});

and here is my html
<body>
<div class="container-fluid">
<div class="row">
<div class="quote-box col-xs-6 col-xs-offset-2">
<div class="quote-text">
<i class="fa fa-quote-left fa-3x" aria-hidden="true"></i>
<span id="text"></span>
</div>
<br>
<button class="btn btn-primary twitter"><i class="fa fa-twitter fa-lg"></i></button>
<button class="btn btn-primary facebook"><i class="fa fa-facebook-official fa-lg"></i></button>
<button class="btn btn-primary getquote">Get Quote</button>
</div>
</div>
</div>
</body>
i have been trying to get this to work for two days now
Johnny
@jtan3
@abhirupleo send your codepen link
leomartin
@abhirupleo
but i can't seem to get any resonse from the site
Netrunner21
@Netrunner21
I have a general question about text() vs html()
leomartin
@abhirupleo
ask i will try to help @Netrunner21
Riley
@Riley1435
ive read .text is more secure than .html. I don't remember why, but i remember reading it.
Netrunner21
@Netrunner21
I see a lot of people using text(), but I'm curious because I think sometimes what's being passed through needs HTML elements tags. My quote generator did, for instance. Wouldn't it be better just to use html() and conver all bases?
cover*
leomartin
@abhirupleo
Not if you
have already styled it and have placed a span
Riley
@Riley1435
i used text() on my quote generator and i remember switching it from html() because i read it was more secure
leomartin
@abhirupleo
then you just need to pass the text you get in response from the ajax request it reduces the complexity ofyour js code
rather than complexity it increases the brevity of your code
using text
why bother with using html tags in js if you can do all the html work in the html file and just pass the text request
it will reduce the mistakes you make
Johnny
@jtan3
@abhirupleo haven't used ajax too often. I have forgotten how to set it up.
Netrunner21
@Netrunner21
The API I used had preset tags such as <p> and <br />. But I understand what you're saying.
this might help @Netrunner21
its okay @jtan3
Netrunner21
@Netrunner21
It also had HTML styling such as &8221; that needed filtering, but that has nothing to do with text() or html()
leomartin
@abhirupleo
yes
Netrunner21
@Netrunner21
@abhirupleo Thats the one I saw about ten minutes ago and prompted the question. I figured why not pass the tags through with HTML where text() sets everything to plain text. I got what you were saying though.
leomartin
@abhirupleo
+1:
kirbyedy
@kirbyedy
@abhirupleo dunno about your code