11-04-2019 12:12 PM - edited 11-04-2019 12:12 PM
I'm trying to implement a 'search' function in my WebVI, interfacing with an external service to do the lookup. The external service is session based, and I'm having trouble figuring out a way to ensure my sessions are always closed cleanly.
My initial thought was to do a standard "initialize" before the while loop and a "cleanup" after, but I quickly realized that wouldn't work unless I had a 'stop' button and could somehow force the user to be unable to close the tab/window without first stopping the application. I can't figure out a way to do that, nor can I think of a way to do it using straight javascript, so I ruled that out. That said, I'm not a javascript wizard, so maybe there is a way that I don't realize.
My second thought was to do everything (open session -> do query operation -> close session) in an event structure frame, linked to the "search" button. That's closer to what I want, but i assume that if I were to close the browser in the middle of the search process, I'd still end up with an orphan session.
Thinking from a web-developer perspective, this seems like something one would normally do in a server-side script (e.g. PHP), so I guess I could build a LabVIEW 20xx web service that implements my search, but I was trying to avoid that.
So, to be clear, my questions are as follows:
11-04-2019 12:20 PM - edited 11-04-2019 12:29 PM
Actually, I didn't realize JS had the onbeforeunload onunload event. That might do what I need; I'll try it out momentarily. I'd still be interested to know if there's a recommended way though.