These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Mar 2018
sabahatullah
@sabahatullah
Mar 26 2018 13:55
working on a challenge project.. trying to pull the slider from a different page to the main page using the following code but its only pulling the headline and not rendering the slider
jQuery.get("https://www.nissan.in/vehicles/new/micra/design.html", function(html){
var cover = $(html).find('.imageGalleryContainer');
$(cover).insertBefore(".pricingStrip")
});
on this page console I am running this code https://www.nissan.in/vehicles/new/micra.html
any help would be massively appreciated
@sjames1958gm
Ken Haduch
@khaduch
Mar 26 2018 14:15
@sabahatullah - did you check the console and see if there are any errors? Like cross-origin errors or something similar? or "no access allowed"?
sabahatullah
@sabahatullah
Mar 26 2018 14:22
@khaduch no error at all. its pulling the header
heading
Ken Haduch
@khaduch
Mar 26 2018 14:39
@sabahatullah - if you console.log the returned page, does it only show the header or does it show more?
sabahatullah
@sabahatullah
Mar 26 2018 14:42
@khaduch the thing is it actually pulls in the html but the classes and actuall render functionality of the carousel is missing
even though the page contains the same js file reference. and when I add that html manually it starts working properly
Ken Haduch
@khaduch
Mar 26 2018 14:48
@sabahatullah - It might be that the carousel involves javascript code that doesn't get executed when you get the page? I guess that I haven't tried anything like this, but I'm guessing about the security aspects and that certain things might not work in a transaction like that? I'm experimenting a little with some simpler pages on CodePen to see how it actually works. The jquery doc page does warn about browser security restrictions, so it's just making me speculate about that.
Ahmad Abdolsaheb
@ahmadabdolsaheb
Mar 26 2018 14:59
Hi everyone, I am trying to dynamically import images but I am running to errors.
Ken Haduch
@khaduch
Mar 26 2018 15:01
@ahmadabdolsaheb - do you have a URL for your page that you are trying this on?
Ahmad Abdolsaheb
@ahmadabdolsaheb
Mar 26 2018 15:01
no I just have a repo.
and here is a snippet
var images = require.context("./assets", true);
{this.state.cards.map((card, index) =>
            <div className="card" key={index}>
              {card.image? <img src={images(card.image)+".svg"} />
                : ""}
)}
Ken Haduch
@khaduch
Mar 26 2018 15:02
@sabahatullah - I cannot get this to work with the simplest pages on CodePen because of "Access-Control-Allow-Origin" errors.
Ahmad Abdolsaheb
@ahmadabdolsaheb
Mar 26 2018 15:02
@khaduch I get Error: Cannot find module '2'. :/
Ken Haduch
@khaduch
Mar 26 2018 15:16
@ahmadabdolsaheb - is this a React project? It almost sounds like it is not loading some required module?
Ahmad Abdolsaheb
@ahmadabdolsaheb
Mar 26 2018 15:17
it is a react project
it loads if I enter a static directory to a file
even then it does not load the file. I have to require it individually :/
Jason Luboff
@JLuboff
Mar 26 2018 15:21
:wave:
Ken Haduch
@khaduch
Mar 26 2018 15:27
@JLuboff :wave: - how are you doing today?
Jason Luboff
@JLuboff
Mar 26 2018 15:28
@khaduch A little tired... the little one didn't want to sleep much last night. Otherwise, not bad, it's a short week. You?
Ken Haduch
@khaduch
Mar 26 2018 15:30
@JLuboff - that's rough when the babies don't want to sleep... we used to have all kinds of problems with that! Not any more... I'm doing okay, just trying to get myself out of first gear so far this morning.
Jason Luboff
@JLuboff
Mar 26 2018 15:35
@khaduch Ya... he has pretty bad eczema and we've been able to get it under control every where but his face... so every hour or two he is waking up really itchy :(
Ken Haduch
@khaduch
Mar 26 2018 15:38
@JLuboff - - that sounds like trouble - hope that you can get that under control.
Jason Luboff
@JLuboff
Mar 26 2018 15:38
@khaduch Thanks, we have some steroid ointment but trying to avoid using it as long term its not very good for them
CamperBot
@camperbot
Mar 26 2018 15:38
jluboff sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3821 | @khaduch |http://www.freecodecamp.org/khaduch
Jason Luboff
@JLuboff
Mar 26 2018 15:39
@khaduch Been doing anything programming wise?
Ken Haduch
@khaduch
Mar 26 2018 15:43
@JLuboff - mostly have been looking at strange problems here in the chat rooms, as far as programming. Trying to put some time on a Python bootcamp course just to get a handle on Python. I keep going only so far with it and then putting it aside and forgetting everything that I got exposure to. So I'm trying to slowly forge ahead on that.
Jason Luboff
@JLuboff
Mar 26 2018 15:53
I hate forgetting stuff :)
sabahatullah
@sabahatullah
Mar 26 2018 16:06
@khaduch "Access-Control-Allow-Origin" error appear when you try pull content from different domains
in my case the website is same and fetch request is from a different page
not different domain
Ken Haduch
@khaduch
Mar 26 2018 16:12
@sabahatullah - it sounds like you're getting some information from the page you are requesting, but I cannot attempt to duplicate your transaction to investigate. My question is - in the html that you are returning, can you console.log it to see what the full content is? My thought is that the carousel might be generated by javascript code, and that might not get set up just in the request that you are making?
sabahatullah
@sabahatullah
Mar 26 2018 16:35
@khaduch Yes I can see the content in the console log. I even can see in the DOM. I think your are right it is probably be generated by Javascript code but does it mean I can not fetch it to different page
The Javascript code that is generating it is in a global file defined in the header.
Hamza Shezad
@hamzashezad
Mar 26 2018 21:10
hey guys
i am working on smallest common multiple challange
i don't quite get it.
here is what i understand: we have to find the lcm of 2 numbers
i don't get this part: "as well as by all sequential numbers in the range between these parameters"
also how would 60 be the answer with [1, 5]?
Dardan Demiri
@dardandmr
Mar 26 2018 21:30

  var max = Math.max(arr[0], arr[1]);
  var min = Math.min(arr[0], arr[1]);
you get the range from Min to Max
@hamzashezad
now you should have a for loop
Hamza Shezad
@hamzashezad
Mar 26 2018 21:32
i've gotten the lcm. but how are they reaching to 60 with [1,5]
i do not understand what is happening
Gulsvi
@gulsvi
Mar 26 2018 21:34
@hamzashezad It's the least common multiple of 1-5 lcm(1,2,3,4,5)
Hamza Shezad
@hamzashezad
Mar 26 2018 21:35
oh i see. let me check again
thanks @gulsvi
CamperBot
@camperbot
Mar 26 2018 21:35
hamzashezad sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2687 | @gulsvi |http://www.freecodecamp.org/gulsvi
Dardan Demiri
@dardandmr
Mar 26 2018 21:35
@hamzashezad Good Luck ;)
Hamza Shezad
@hamzashezad
Mar 26 2018 21:36
thanks @dardandmr :)
CamperBot
@camperbot
Mar 26 2018 21:36
hamzashezad sends brownie points to @dardandmr :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @dardandmr |http://www.freecodecamp.org/dardandmr
Dardan Demiri
@dardandmr
Mar 26 2018 21:36
You are welcome
Hamza Shezad
@hamzashezad
Mar 26 2018 21:37
my code right now is strictly for 2 numbers only :sparkles: