I'm execting a STP in a new from my main web page.
<form target="_blank" action="http://<UrlToMySTP>" method="get" enctype="multipart/form-data">
And I would like it to close automatically when it's done.
data _null_; file _webout; put '<HTML>'; put ' <HEAD>'; put ' </HEAD>'; put ' <BODY onLoad="window.close()">'; put ' </BODY>'; put '</HTML>'; run;
but the browsers don't allow that (security vulnerability)
Scripts may close only the windows that were opened by it.
Is there another way to close the page?
When a button is clicked, something needs to be done in SAS, (for example delete a record in a table).
and that just needs to be done in a separate window
that window is empty is empty and doesn't need to stay open.
I wan to avoid the user having to close the empty window manually.
On another case I used a redirect, because I could afford a page refresh, not this time.
I found a way to just call the STP with ajax. But that was more difficult than I thought necessary.
The tool doesn't require it.. Your SAS server is configured to require it. You will have the same issue regardless of whether the adapter is used or not, if building web apps on SAS using ajax.
If your site does not permit your web files to be served from the SAS Web server, you can always ask for your preferred web server to be whitelisted. And use chrome with CORS disabled in the meantime. This approach is taken by many of our clients. It is far preferable to do these things properly than to have to maintain a web application composed of put statements / proc stream / whatever...
You don't have CORS issues when using "jsonp", no need to whitelist the webserver on the sasserver.
(at least I don't, maybe it's different on different setups)
And the put statements that write an empty html page are very little in this case.
The thing with JSONP is that you can't make POST requests, which means you're limited to simple URL-encoded parameter values when sending data to SAS. It's also... a bit of a hack.
I'm not a fan of it, but I'll have a chat to our devs and see if there's a way we can implement it as an optional transport mechanism. Will keep you posted.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.