# Having Problems With Ajax/Fetch Method

**URL:** <https://forum.djangoproject.com/t/having-problems-with-ajax-fetch-method/7877>\
**Category:** Using Django\
**Created:** [May 11, 2021, 12:06pm UTC](https://forum.djangoproject.com/t/having-problems-with-ajax-fetch-method/7877 "2021-05-11T12:06:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![firaki12345](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/firaki12345/32/4251_2.png) [@firaki12345](https://forum.djangoproject.com/u/firaki12345)\
**Post date:** [May 11, 2021, 12:06pm UTC](https://forum.djangoproject.com/t/having-problems-with-ajax-fetch-method/7877/1 "2021-05-11T12:06:51Z")

</div>

Hi, i am trying to load data through Ajax, it console logs perfectly but does not appear in my webpage, can anyone help please 🙂

**My Views File:**

```
def post_data(request):

qs = Post.objects.all()

data = []

for obj in qs:

item = {

'title': obj.title,

}

data.append(item)

return JsonResponse({"data": data})

```

**My JavaScript File:**

```
const pb = document.getElementById("post-box")

async function Start1() {
	const a = await fetch("data/")
	const data = await a.json()
	console.log(data)
	renderHTML(data)
}

Start1()

function renderHTML (OurData) {
	var htmlstring =""
	for (i=0; i < OurData.length; i++){
		htmlstring += `<p> ${OurData[i]} </p>`
	} 
	pb.insertAdjacentHTML("beforeend",htmlstring)

```

**It console logs perfectly: here is the pic**

 ![](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/5/53daa0a06f0f8d69dff6d8d589f33d846c1790bb.png)

---

<div class="post-metadata">

**Author:** ![marcorichetta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcorichetta/32/26473_2.png) [@marcorichetta](https://forum.djangoproject.com/u/marcorichetta)\
**Post date:** [May 11, 2021, 1:01pm UTC](https://forum.djangoproject.com/t/having-problems-with-ajax-fetch-method/7877/2 "2021-05-11T13:01:33Z")

</div>

I think this is more of a Javascript issue rather than a Django one.

It gets to the `console.log` statement and then?  
I suggest you to follow what’s happening inside your `renderHTML` function using the browser debugger.

> **[The Firefox JavaScript Debugger - Firefox Developer Tools | MDN](https://developer.mozilla.org/en-US/docs/Tools/Debugger)**
>
> The JavaScript Debugger enables you to step through JavaScript code and examine or modify its state to help track down bugs.

---

<div class="post-metadata">

**Author:** ![firaki12345](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/firaki12345/32/4251_2.png) [@firaki12345](https://forum.djangoproject.com/u/firaki12345)\
**Post date:** [May 11, 2021, 1:23pm UTC](https://forum.djangoproject.com/t/having-problems-with-ajax-fetch-method/7877/3 "2021-05-11T13:23:21Z")

</div>

hi i fixed it by calling OurData.data[i]

i was not putting the .data that’s all

thank you for your time 🙂
