Say I have a web page and I want it to automatically "go to" some form. This sort of thing works fine:
script(type = 'text/javascript').
var ff = document.createElement("form")
document.body.appendChild(ff)
var ii = document.createElement("input")
ii.setAttribute("type","hidden")
ii.setAttribute("height", 69)
ff.appendChild(ii)
ff.method = "POST"
ff.action = window.location + "/someform"
ff.submit()
However, it's much easier to use fetch to send a form:
script(type = 'text/javascript').
fetch("/someform", {
method: "POST",
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({height: 69})
})
However that does not actually "go to" the new page, /someform.
Is there actually a way to make fetch "go to" the form in question, rather than just fetch the results behind the scene?
script(type = 'text/javascript').? Additionally, you should definitely get in the habit of terminating statements with semicolons. Omitting those commonly leads to strange bugs.)fetch.. is there actually a way to makefetch"go to" the form in question, rather than just fetch the results behind the scene? TYfetchdoesn't perform a navigation. But if you want to perform a navigation then you can do that in JavaScript. Have you tried that?