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
GrumpyCoder
@grumpycoder100
Guys how do I make a text be in centre?
*center
Building my Tribute Page currently
Markus Ivancsics
@ivancsicsmarkus
@grumpycoder100 css:text-align: center
kirontoo
@kirontoo
@grumpycoder100 select the element and use text-align: center
alpox
@alpox
@shivamg11000 What you are doing there is no ajax at all. It would be an unfinished way of doing jsonp
@shivamg11000 does anything speak against using jquery for the request?
shivam gupta
@shivamg11000
@alpox I changed the code
alpox
@alpox
@shivamg11000 It still looks like that - maybe you didn't save?
shivam gupta
@shivamg11000
@alpox now i a trying with open weather api
alpox
@alpox
@shivamg11000 That won't work because the open weather api has no free plan for https - and codepen allows only https now
shivam gupta
@shivamg11000
Its working on my pc but not on codepen bcs on codepen http:// is not supported
Tring to do jsonp
alpox
@alpox
@shivamg11000 yes. You cannot use open weather api
Not through codepen
@shivamg11000 If you want to go with jsonp, best is to use jquery for it - otherwise you have to do quite a setup for it
Nastya
@a4evo

help me please! Whats wrong?
```function getForecast() {
var lat = "";
var lon = "";

if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
        lat = position.coords.latitude;
        lon = position.coords.longitude;
        $(".lat").text(lat);
        $(".lon").text(lon);

        var linkAPI = '"https://api.darksky.net/forecast/dd5fb835130b53a3a354d5687b74f6c8/' + lat + ',' + lon + '"';
        $.getJSON(linkAPI, function(json) {
            //$(".api").text(linkAPI);
            $(".api").text(JSON.stringify(json));
        });
    });    
}        

}```
i get coords, link forms right, but i can't get json ((

alpox
@alpox
@a4evo Its likely that you run into a CORS problem. Try adding ?callback=? to your url (At the end)
Nastya
@a4evo
@alpox i love you! Thanks! It worked!!!!
CamperBot
@camperbot
a4evo sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1155 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
@a4evo np :-)
Piyush Tiwari
@piyush805
For random quote machine.
I want to get .JSON file as an array.
Here i found solution for that https://stackoverflow.com/questions/14540248/how-to-get-an-array-javascript-of-json-file
Then generate a random number and print array object from $(".message" ) in function(json).
How do i do later part? Does JQuery take input like array[num]?
Piyush Tiwari
@piyush805
Anyone there?
Nastya
@a4evo
@piyush805 i used quotesondesign.com, the give a random quote
Piyush Tiwari
@piyush805
API v3.0 @a4evo ?
@piyush805 i don't see a need in array in this case, object is ok
Piyush Tiwari
@piyush805
I asked for help yesterday and someone who had done it told to use this as an array and print random object, so i was trying that
teevik
@teevik
@piyush805 I would recomment using console.log to see how the array you fetch is built
Nastya
@a4evo
@piyush805 it's already an array of objects, what's the problem?
Piyush Tiwari
@piyush805
@a4evo I generate a random whole number, feed it to array, then how do i get it int the JQuery code where events trigger with click.
$("#getMessage").on("click", function(){
      // Only change code below this line.
      $.getJSON("https://gist.githubusercontent.com/dmakk767/9375ff01aff76f1788aead1df9a66338/raw/491f8c2e91b7d3b8f1c8230e32d9c9bc1a1adfa6/Quotes.json%2520", function(json) {
$(".message").html(array[num]);

});


});
There is array[num] is doesnt work^
teevik
@teevik
The array[num] is just a standard object
so array[num].key gives the value for that key
Piyush Tiwari
@piyush805
$(".message").html(JSON.stringify(json));
There was this which was returning entire page on click
Nastya
@a4evo
@piyush805 don't you need to generate that num first? and what is array?
teevik
@teevik
Json.stringify turns an object into a string
Piyush Tiwari
@piyush805
@teevik I only know what all I learnt from challenges :worried:
Nastya
@a4evo
$(".message").html(json[0]); try this
Piyush Tiwari
@piyush805
@a4evo I generated number and array in Javascript panel
Nastya
@a4evo
@piyush805 the num should be generated on click, as i understand. And you don't need a new array, json you get is already an array
Piyush Tiwari
@piyush805
teevik
@teevik
Why do you fetch it twice?
Once in html and once in js
Piyush Tiwari
@piyush805
@teevik Exactly! See, the click event happens in js and random number is generated in Html. I am not able to connect the two via code
teevik
@teevik
You can just run all the code in js part, no difference