by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 19 20:09
    @krisb1220 banned @Gastony
  • May 14 22:39
    @bjorno43 banned @minitechtips_twitter
  • May 14 22:38
    @bjorno43 banned @real-action
  • Feb 01 00:27
    @bjorno43 banned @Ndoua
  • Jan 07 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 2019 17:13
    @mstellaluna banned @cmal
  • Jan 08 2019 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
Thomas Mullen
@t-mullen
@danielbyun Link to the site?
vínαч puppαl
@vinaypuppal
Tony
@FreakishLancer
Been adding some more touches to my Simon game and still can't quite figure out how to make the game state reset to original when pressing the power/play button on and off and on again (I just ended up disabling it so the user can't break it). Can anyone help? http://codepen.io/Freaklancer/pen/BpOEvO
Daniel
@doodleslr
Hey guys does anyone have good knowledge of .when() and .then()?
I've made global array variables and assigned json data to the variables inside the .when() functions but they act local so i can't refer to the variable inside my .then() function it's just returning the original empty array variable
vanessamuller
@vanessamuller
hey does anyone know why geolocation might not be working in codepen?
it is also not working on my local host
Daniel
@doodleslr
does it say something about requiring https?
vanessamuller
@vanessamuller
I have the same code that I have on free code camp
it said something about that before so I went to the settigns and local host is supposed to have a excepetion so that geolocation can be accessed
but the local host is not showing my geolocation
I thought if I did it on an outside editor and launch a local host I would be able to get it but it doesn't seem that way
Daniel
@doodleslr
i think it blocks it since it's accessing a local file and assumes it's for some malicious purpose, you can try
http://ip-api.com/json
i've had good results getting lat and lon with it if that's what you're chasing
vanessamuller
@vanessamuller
yes that's what im looking for
thank you I'll read the documentation to see how to use that api
Daniel
@doodleslr
no worries
can anyone figure out why my userWeather variable wont work in my .then() function?
var arrLocat = [];//location
var userURL = "";
var userWeather = [];

$(document).ready(function(){
  $.when(//waits for both GET requests to complete
    //first JSON request
    $.getJSON("http://ip-api.com/json", function (data){
     arrLocat = data;
     userURL = "http://api.openweathermap.org/data/2.5/weather?lat=" + arrLocat.lat + "&lon=" + arrLocat.lon + "&appid=61c4ebe6f40d2e2d7085e7c42d287e1d&units=metric";
      //second JSON request
     $.getJSON(userURL, function(index){
       userWeather = index;
       //console.log(userWeather);//this one works!
     });
    })
    //end when, GET waiting
  ).then(function(){//do stuff here to update page
    $("#locat").text(arrLocat.city + ", " + arrLocat.regionName + ", " + arrLocat.country);
    console.log(userWeather);//wont log, the userWeather doesnt carry
  });


});
Tyler Moeller
@TylerMoeller
@doodleslr This is an example I made this morning, with the data getting passed back from the async functions to the .then() method: http://s.codepen.io/TylerMoeller/pen/bgQYQe
Daniel
@doodleslr
arrLocat works in the console.log at the bottom but userWeather does not..??
Tyler Moeller
@TylerMoeller
For the weather app, you shouldn't need to do that though - it can all go in the callback function where you have "this one works!"
Daniel
@doodleslr
i was hoping to have all the data required and use that to personalise the page based on the weather, but since its all async i thought i'd let it wait until all the json had loaded and then begin "prettying" up the page
hence the when and then
Skullvapor
@Skullvapor
How can I make this F work so that it is next to the word? https://codepen.io/Skullvapor/pen/JEvVzv?editors=1100
Daniel
@doodleslr
would it be better to write the function in .then as a variable as in your example instead of lumping all the code it all in the .then? @TylerMoeller
Tyler Moeller
@TylerMoeller
@doodleslr You can do all of that like:
$.getJSON(locationUrl, function(locationData) {
  // use locationData to construct the weather url
  $.getJSON(weatherUrl, function(weatherData) {
    // access locationData and weatherData here
    // or pass it to a function: displayData(locationData, weatherData);
  });
});
rachiscuy
@rachiscuy

This is probably really trivial for most of you, I posted in the regular "help" chat but haven't had any responses. Can someone take a look at this and tell me where I've gone wrong?

<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6">
<div class="well">
<form type="button" class="btn btn-primary"></form>
<form type="button" class="btn btn-primary"></form>
<form type="button" class="btn btn-primary"></form>
</div>
</div>
<div class="col-xs-6">
<div class="well">
<form type="button" class="btn btn-primary"></form>
<form type="button" class="btn btn-primary"></form>
<form type="button" class="btn btn-primary"></form>
</div>
</div>
</div>
</div>

Nest three button elements within each of your div elements with class well.
You should have a total of 6 button elements.
Make sure all your button elements have closing tags.
HALP

Daniel
@doodleslr
but any visuals i need to do would happen before the json loads like that, i'll deal with that bridge when i come to it though
Tyler Moeller
@TylerMoeller
@rachiscuy Where is your <button> element?
Daniel
@doodleslr
it's just the userWeather = index not carrying over from the .when to the .then
rachiscuy
@rachiscuy
@TylerMoeller got it, thank ya!
CamperBot
@camperbot
rachiscuy sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1482 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
vanessamuller
@vanessamuller
can anyone tell me what I am doing wrong? The alert says that the value is undefined and I don't get why
Daniel
@doodleslr
but that makes it local to the .when, but i made it global outside so i can get it into the .then
Tyler Moeller
@TylerMoeller
$.when runs deferred objects all at once and holds on to their data until they report back. In .then() you can process their return values.
vanessamuller
@vanessamuller
hey can anyone tell me what I'm doing wrong? when the alert appears it tells me the value is undefined

$(document).ready(function(){
var lat;
var lon;

$.getJSON("http://ip-api.com/json",function(data){
lat = data.lat;
lon = data.lon;

});

alert(lat);
});

Tyler Moeller
@TylerMoeller
If you want to try and use $.when for this, you'll need to create separate functions, wrap them in $.Deferred and resolve their data when complete
Daniel
@doodleslr
hmmmmmmmm
ok i'll check out deferred objects, thank you @TylerMoeller
CamperBot
@camperbot
doodleslr sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1483 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Tyler Moeller
@TylerMoeller
@vanessamuller It's a similar issue to what @doodleslr is facing. $.getJSON is asynchronous. It takes some time to go out to the server and get the location data. By the time that data comes back, your alert(lat); has already run.
Put everything inside the function(data) { } portion of your $.getJSON
vanessamuller
@vanessamuller
yes when I ut the alert inside it does work
but I am actually doing the alert to test if it was working I actually need the lat and lon for another api
Tyler Moeller
@TylerMoeller
@vanessamuller Maybe this code example would help: :point_up: February 10, 2017 5:36 PM
vanessamuller
@vanessamuller
ok great let me take a llok at that thanks!
eshaffer321
@eshaffer321

Hey guys I have a question! I wanted to edit an image thats in a div class using css but i can't get it to work. Let me know what I'm doing wrong

<div class = "media1">
<h2>GitHub</h2>
<a href="#"> <img class ="image" src="https://image.flaticon.com/icons/svg/25/25231.svg" ></a>
<p>Check out some of my public repositories and open source contributions</p>
</div>

CSS FILE
.media1 > a {

width: 100px;

}

if i use .media1 > img {} it doesnt work either