Can I write ASP code in a .js file. Or if there is any way through which I can update database in a .js file.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
If you mean that you want to use server-side scripting to generate your
.js
files, Dan's answer helps you there.If you mean you want to use Javascript as your server-side ASP language, yes, you can do that. You can set it up by configuration (changing the default langauge from VBScript to JScript), or you can do it explicitly per-file. I do the latter, just because the overwhelming assumption is that
.asp
pages are written in VBScript. Here's an example:I do this in any Classic ASP app I write, because that way I'm using the same language on the client and the server. I frequently code up a piece of abstract functionality that ends up being in both places (via includes). Very efficient. :-)
Technically, yes.
You need to add the js extension to IIS and the web.config file:
The other option (which I recommend) is request an .asp file, like this:
And yourASPfile.asp would send a javascript header:
Although technically, you don't need to set the header.
Now you can write asp/javascript and it gets parsed by the server THEN delivered to the browser to be used.