problem is: "run in the browser" is usually "run on server, wrapped in requests and responses from and to the browser", i.e.
-
browser sends request to server
-
server runs script
-
server sends response back
-
Browser renders response
and if it "fails/does not work", you have to find out
which of these four steps is at fault, and decompose that further...