These are chat archives for FreeCodeCamp/HelpJavaScript

25th
Mar 2018
Adel
@AdelMahjoub
Mar 25 2018 00:26
unlocked the final test, and it execute less than the time limit ...
不吃猫的鱼
@n0ruSh
Mar 25 2018 02:42
For people who are learning JS, just thought this might help: https://github.com/n0ruSh/the-art-of-reading
Johnny
@JohnnyBizzel
Mar 25 2018 09:22
@n0ruSh Useful. Thanks
CamperBot
@camperbot
Mar 25 2018 09:22
johnnybizzel sends brownie points to @n0rush :sparkles: :thumbsup: :sparkles:
:cookie: 13 | @n0rush |http://www.freecodecamp.org/n0rush
Dingly Do
@dinglydo
Mar 25 2018 17:26
So I wanna go from jQuery to pure Javascript, the code that I am having trouble converting is this
    $.ajax(
        {
            type: "GET",
            url: JSONURL,
            success: BuildHTML,
            cache: false
        });
I tried to imitate this function using the XMLHttpRequest and so it looked like this
    var request = new XMLHttpRequest();
    request.open("GET", JSONURL, true);
    request.onload = function() {BuildHTML(JSON.parse(request.responseText));};
    request.send();
However, there is a difference between these two, the first one that uses jQuery works perfectly, it gets the random quote for me just fine, however the second one with pure Javascript keeps returning the same quote no matter what
And so my question is, what is the difference between how these two work and how could I fix it?
image.png
image.png
Stephen James
@sjames1958gm
Mar 25 2018 17:31
@dinglydo the first one you are setting cache to false so you get a new request every time
Dingly Do
@dinglydo
Mar 25 2018 17:31
Ahhh, and for the second one the cache is true by default which means that it just uses whatever is stored in the cache?
Stephen James
@sjames1958gm
Mar 25 2018 17:32
Yes. Search on SO for “XMLHttpRequest cache false” for various solutions
Dingly Do
@dinglydo
Mar 25 2018 17:33
Alright, @sjames1958gm Thanks a lot
CamperBot
@camperbot
Mar 25 2018 17:33
dinglydo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9133 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
Mar 25 2018 17:33
:+1:
Moisés Man
@moigithub
Mar 25 2018 17:34
what jquery cache:false does behind scene is add some useless random parameter (timestamp) to ur url address http://api.jquery.com/jquery.ajax/
Dingly Do
@dinglydo
Mar 25 2018 17:36
@moigithub Ya I just saw that as I was looking it up, weird how browsers can't just let you disable the cache
Dardan Demiri
@dardandmr
Mar 25 2018 20:25
var MoneyType = {
    PENNY:0.01,
    NICKEL:0.05,
    DIME:0.10,
    QUARTER:0.25,
    ONE:1.00,
    FIVE:5.00,
    TEN:10.00,
    TWENTY:20.00,
    HUNDRED:100.00,
  };
I think this are the only types or am I wrong ?
Thanks :-1:
:P
Stephen James
@sjames1958gm
Mar 25 2018 21:23
@dardandmr Yeah, those are all of them, probably a bit late of an answer :)
JeremyHaynes310
@JeremyHaynes310
Mar 25 2018 21:41
rooms
CamperBot
@camperbot
Mar 25 2018 21:41

freeCodeCamp rooms:

:point_right: Here is a list of our official chat rooms
Dardan Demiri
@dardandmr
Mar 25 2018 22:11
@sjames1958gm :+1: