gorgeous-airport-54386
12/31/2021, 4:02 PMas json goes before`with`gorgeous-airport-54386
12/31/2021, 4:03 PMGET to JSON which puts quotes around itgorgeous-ghost-95789
12/31/2021, 4:03 PMhx-post to the button to call the server when it's clicked. You can use hx-target on the button to choose where the returned HTML will go. Or, have the server choose what gets changed by returning content with an hx-swap-oob attribute. Or, if you don't want to have the page update at all, use hx-swap="none".mysterious-toddler-20573
12/31/2021, 4:03 PMmysterious-toddler-20573
12/31/2021, 4:04 PMmysterious-toddler-20573
12/31/2021, 4:04 PMwith goes before the asmysterious-toddler-20573
12/31/2021, 4:04 PMmysterious-toddler-20573
12/31/2021, 4:05 PMwith clause the as is captured by the inner expressionuser
12/31/2021, 4:12 PMon click fetch https://swapi.dev/api/planets/1/ as json with method:"GET" then put it into #planet.innerHTML
All I receive is a: Error: Unexpected Token : withmysterious-toddler-20573
12/31/2021, 4:13 PMmysterious-toddler-20573
12/31/2021, 4:13 PMmysterious-toddler-20573
12/31/2021, 4:14 PMapplescript
on click fetch https://swapi.dev/api/planets/1/ as json then put it into #planet.innerHTMLmysterious-toddler-20573
12/31/2021, 4:15 PMmysterious-toddler-20573
12/31/2021, 4:15 PMuser
12/31/2021, 4:16 PMmysterious-toddler-20573
12/31/2021, 4:17 PMapplescript
on click fetch https://swapi.dev/api/planets/1/ {method:"GET"} as json then put it into #planet.innerHTMLuser
12/31/2021, 4:21 PMuser
12/31/2021, 4:22 PMon click fetch https://swapi.dev/api/planets/1/ {method:"GET"} as json then put result["name"] into #planet.innerHTMLmysterious-toddler-20573
12/31/2021, 4:25 PMapplescript
on click fetch https://swapi.dev/api/planets/1/ {method:"GET"} as json
put the result's name into the #planetmysterious-toddler-20573
12/31/2021, 4:25 PMmysterious-toddler-20573
12/31/2021, 4:28 PMuser
12/31/2021, 4:36 PMmysterious-toddler-20573
12/31/2021, 4:38 PMuser
12/31/2021, 4:38 PMuser
12/31/2021, 4:39 PMmysterious-toddler-20573
12/31/2021, 4:39 PMhtml
<button _="on click fetch https://swapi.dev/api/planets/1/ {method:'GET'} as json
put the result's name into the #planet">
Get The Planet Name
</button>mysterious-toddler-20573
12/31/2021, 4:39 PMmysterious-toddler-20573
12/31/2021, 4:40 PMapplescript
on click fetch https://swapi.dev/api/planets/1/ with {method:"GET"} as json
put the result's name into the #planetmysterious-toddler-20573
12/31/2021, 4:40 PMabundant-breakfast-94967
12/31/2021, 5:39 PMjavascript
document.body.addEventListener('htmx:configRequest', (event) => {
event.detail.headers['X-CSRFToken'] = '<token h';
})
However, it seems that the X-CSRFToken is not added to headers in internet explorer. It seems like a straightforward script, would I expect there to potentially be an issue on the htmx side with IE11 support?
This works as expected on... moderns browsers 😄