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
Kim Duclos
@KimberlyDuclos
After pressing enter to search, I'm not getting any JSON output. Can anybody check this out for me? Thanks. https://codepen.io/KimberlyDuclos/pen/ZxJRyx
John
@tertiaryidentifier
@KimberlyDuclos I think your url is off
Kim Duclos
@KimberlyDuclos
ah, the wikipedia URL?
John
@tertiaryidentifier
@KimberlyDuclos also unrelated but if you are working in jQuery, why don't you just $("#textInput").val() instead of the lengthier document.getElementById('').value
Kim Duclos
@KimberlyDuclos
Yeah, I need to switch. Just got in the habit of document.getElementById while learning. I'm planning on cleaning up my code once I get things working.
Santiago Fernandez
@sf-jd
@KimberlyDuclos i believe you are submitting the search form, what you need to do is prevent its default behavior and then let your getJSON handle. I suspect its submitting a form because it causes a redirect.
Kim Duclos
@KimberlyDuclos
So, when hitting enter, all I'm doing is generating a search yet it's not leading to the search output?
Santiago Fernandez
@sf-jd
It is most likely doing whatever you told the form to do
its default behavior
please take 5 mins to read about preventDefault() method you'll figure it out in no time :D
        $('#search').submit();
Kim Duclos
@KimberlyDuclos
OK, thanks. I'll take a look at that. So it seems that I have a form that performs a search yet does not output search results.
Santiago Fernandez
@sf-jd
thats what's submitting your form
Kim Duclos
@KimberlyDuclos
Ah ok, and that would have no power to actually make output.
Santiago Fernandez
@sf-jd
the form is not being told to do anything that would produce output
Kim Duclos
@KimberlyDuclos
I see now. The form is just taking the user input and doing nothing with it then.
Santiago Fernandez
@sf-jd
Yup
Kim Duclos
@KimberlyDuclos
Thanks. Time to do some reading!
Moisés Man
@moigithub
instead u code in keydown event.. u could do in submit event
then no need to track keycode 13
just use default form behavior (submit)
Kim Duclos
@KimberlyDuclos
OK, thanks.
John
@tertiaryidentifier
hey folks, if I receive an object from an API that looks like this:
{
{
{
{}
whoops sorry ignore that hold on
Santiago Fernandez
@sf-jd
Lol i was just using your name @moigithub
i sliced the results for https://codepen.io/sf-jd/full/Gxvqov/ at 7 and your name came up last in the all timers
Moisés Man
@moigithub
:O
John
@tertiaryidentifier
essentially: I am receiving a JSON object and I don't know how to iterate through a nested object. it would be great if I could save that part as an array. I have tried doing some research but I haven't found a quick intuitive way to do this
Santiago Fernandez
@sf-jd
(for key in keys)
Array.from(object).map()
John
@tertiaryidentifier
okay thank you let me try that
Santiago Fernandez
@sf-jd
:)
John
@tertiaryidentifier
I tried for key in keys earlier but it wasn't really working
grrrrrrr
Moisés Man
@moigithub
thats a nested object....
John
@tertiaryidentifier
I am confused....
Moisés Man
@moigithub
keys in keys or array.from or Object.keys
would work if ur "target" object looks like
{a: somevalue1, b: somevalue2, c: somevalue3}
a single object with many keys:value pairs
else it will give u only 1 result
John
@tertiaryidentifier
yep, there's an object like that nested within the larger JSON object
Santiago Fernandez
@sf-jd
does the wiki api return an object? i thoguht it returned an array of objects
Moisés Man
@moigithub
then first u need to access that nested object
John
@tertiaryidentifier
yes, wiki api returns an object, and yes I am accessing that nested object
Santiago Fernandez
@sf-jd
i thought it returned an array, wtf lol
John
@tertiaryidentifier
let me show you my call holdon
Santiago Fernandez
@sf-jd
im opening your pen
Santiago Fernandez
@sf-jd
btw you also need a preventDefault there
John
@tertiaryidentifier
yeah I realized I did the button wrong, going to remove the button and preventDefault on just enter key, want to figure out results first
Santiago Fernandez
@sf-jd
line 8, pass an e to your function and drop the e.preventDefault() else youre redirecting to a blank page
you might want to start googling for the fix on index.html:1 Failed to load https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=test&callback=JSON_CALLBACK: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
John
@tertiaryidentifier
where did you see that error?