Message from JavaScript discussions

October 2020

— Then what is the way

— 

HTTP APIs.
E.g. you have a file change.php that does what you need, with javascript you can dynamically retrieve the content and display it.

e.g.:

const change = async () => {
const response = await fetch('/change.php')
const text = await response.text()
document.querySelector('#content').innerHTML = text
}

— Will I get my desired result

— I think so

— But..if you want to redirect to another location, you don't need php

— You can simply do location = 'register'

— Or you just use native HTML and do:
<a href="register.php">click this to register</a>

— No js or php needed at all

— It download the file not redirect to the page

— 🤔 how so? what does register.php do?

— Signup screen

— Are you maybe setting a content disposition header or similar? what happens if you go to register.php directly?

Message permanent page