0

I would like to add a header to the following request but unsure how to add it?

"Accept":"application/json; odata=verbose";

Here is my code:

function getArticleList() {
 var ajax = new XMLHttpRequest();
 ajax.open("GET", "/content/_api/web/lists/getbytitle('topsupportarticles')/items?", true);
 ajax.onload = function () {
 var list = JSON.parse(ajax.responseText).map(function (i) { return i.Title + "<p id='dt'>-" + i.KBID + "</p>"; });
 console.log(i.Title + " " + i.KBID);
 //new Awesomplete(document.querySelector("#Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField"), { list: list });
 // $(".input-loader").css("background-image", "none");
 };
 ajax.send();
 }
halfer
20.2k19 gold badges110 silver badges207 bronze badges
asked Jul 26, 2016 at 16:11

2 Answers 2

2

Here is link to documentation for XMLHttpRequest https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader

Is that what you are looking for?

answered Jul 26, 2016 at 16:22
Sign up to request clarification or add additional context in comments.

Comments

2

You may use it like:

ajax.setRequestHeader("Accept","application/json");
answered Jul 26, 2016 at 16:39

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.