0

first of all im pretty new to programming with golang. I already made some things like a Homepage that parses a different Body Template if a different Handler is given, while having a static header and footer Template. So my question is, how can i change the Content of my Body without reloading the Page? Like if a User starts to click on a link to a different Site, then it should only load a new Template and not the Page. I thought about doing it with Websockets but maybe there is a better way to do this?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
J.Mllr
  • 1
  • 1
  • 1
    You don't need to use websockets for this, just use javascript and its xhr capability. And it is up to you to decide whether the partial html is constructed on the server and sent to the client or whether the client is going to be responsible for that, both can be done. – mkopriva Aug 19 '18 at 11:25
  • 1
    You mostly need some front-end framework like the likes of angularjs or jquery with ajax – Sushant Aug 19 '18 at 11:58
  • If you want you can use wasm with go now, but yes, it is front-end rendering logic instead of communication protocol like web-socket. – leaf bebop Aug 19 '18 at 12:02
  • wow thanks for the Response guys! I guess i will then stick with javascript and try to do it. @leafbebop silly me i thought it may be possible to change the loaded Template with Golang if i would get to know what the user clicked. But i think even that doesnt make sense :D – J.Mllr Aug 19 '18 at 12:21

0 Answers0