Skip to content

Instantly share code, notes, and snippets.

@itsMapleLeaf
Last active June 7, 2016 15:41
Show Gist options
  • Save itsMapleLeaf/f2803de4554d1f1123bc0924aaad6dc5 to your computer and use it in GitHub Desktop.
Save itsMapleLeaf/f2803de4554d1f1123bc0924aaad6dc5 to your computer and use it in GitHub Desktop.
JSON request error "invalid username"
const encode = encodeURIComponent
const url = "https://www.f-list.net/json/getApiTicket.php"
const params = `account=${encode(account)}&password=${encode(password)}`
const request = new XMLHttpRequest
request.onreadystatechange = function () {
if (request.readyState === XMLHttpRequest.DONE && request.status === 200) {
console.log(request.responseText)
}
}
request.open('POST', url, true)
request.setRequestHeader('Content-Type', 'application/x-www-url-encoded')
request.send(params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment