# JSON response not coming in console.log while the url is correct

**URL:** <https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411>\
**Category:** General\
**Tags:** ajax, json, wikipedia-api, console\
**Created:** [June 9, 2017, 3:23pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411 "2017-06-09T15:23:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![harshTTH](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/harshtth/32/55219_2.png) [@harshTTH](https://forum.freecodecamp.org/u/harshTTH)\
**Post date:** [June 9, 2017, 3:23pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/1 "2017-06-09T15:23:14Z")

</div>

I am using a form to get search query and as per log results URL is correct on clicking URL JSON response is opening, but doing ajax call with same URL is not showing up JSON data , even no error.

 ![](https://global.discourse-cdn.com/freecodecamp/original/3X/d/7/d700b435a93a5b4ed955826b6f939c297e2a621d.png)

[codepen link](https://codepen.io/harsh456/pen/bREWwG)

---

<div class="post-metadata">

**Author:** ![owel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/owel/32/48425_2.png) [@owel](https://forum.freecodecamp.org/u/owel)\
**Post date:** [June 9, 2017, 3:28pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/2 "2017-06-09T15:28:06Z")

</div>

Click the Network tab, and refresh page to see where in the communication the breakdown happens.

my guess is you need to use [https://cors-anywhere.herokuapp.com/](https://cors-anywhere.herokuapp.com/)

---

<div class="post-metadata">

**Author:** ![harshTTH](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/harshtth/32/55219_2.png) [@harshTTH](https://forum.freecodecamp.org/u/harshTTH)\
**Post date:** [June 9, 2017, 3:34pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/3 "2017-06-09T15:34:38Z")

</div>

the main thing is there is no network activity no JSON data is shown being retrieved

---

<div class="post-metadata">

**Author:** ![owel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/owel/32/48425_2.png) [@owel](https://forum.freecodecamp.org/u/owel)\
**Post date:** [June 9, 2017, 3:43pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/4 "2017-06-09T15:43:34Z")

</div>

Can you post the link to your codepen… you’ll get more responses.

---

<div class="post-metadata">

**Author:** ![harshTTH](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/harshtth/32/55219_2.png) [@harshTTH](https://forum.freecodecamp.org/u/harshTTH)\
**Post date:** [June 9, 2017, 3:59pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/5 "2017-06-09T15:59:40Z")

</div>

i have updated the post with link

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [June 9, 2017, 4:04pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/6 "2017-06-09T16:04:29Z")

</div>

Your page is refreshing when the form is submitted. Add `evn.preventDefault();` in your submit callback.

---

<div class="post-metadata">

**Author:** ![harshTTH](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/harshtth/32/55219_2.png) [@harshTTH](https://forum.freecodecamp.org/u/harshTTH)\
**Post date:** [June 9, 2017, 4:11pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/7 "2017-06-09T16:11:57Z")

</div>

Thanx man now it is working But if the form is refreshing than why will json response will not come up,  
can you plz explain the issue .

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [June 9, 2017, 4:17pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/8 "2017-06-09T16:17:44Z")

</div>

You’re getting a response, but you’re getting this error:  
`TypeError: response.query.pages[0] is undefined`

---

<div class="post-metadata">

**Author:** ![harshTTH](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/harshtth/32/55219_2.png) [@harshTTH](https://forum.freecodecamp.org/u/harshTTH)\
**Post date:** [June 9, 2017, 5:22pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/9 "2017-06-09T17:22:08Z")

</div>

I got it now! Once Again Thank You for the help!

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 6:00pm UTC](https://forum.freecodecamp.org/t/json-response-not-coming-in-console-log-while-the-url-is-correct/125411/10 "2021-01-16T18:00:30Z")

</div>

Closed on January 16, 2021, 6:00pm UTC


