0

I have page index.asp in this file i have Vbscript function:

<%
Dim GetFromVbscript
GetFromVbscript = "hello"
%>

And javascript function

function SendFiltered() {

        $.ajax({
            url: '/Filtered.asp',
            type: 'POST',
            data: "<%=GetFromVbscript%>",
            dataType: 'text',
            success: function (data) {
                $(".center").html(data)
            }
        });
    };

It ok. It Post "hello".

Now I need to run this javascript from external file so my index.asp now look like

<%
Dim GetFromVbscript
GetFromVbscript = "hello"
%>
<script src="js/SendFiltered.js"></script>

But now it Post "<%=GetFromVbscript%>"

So question is How to pass value or variable from VBscript to javascript?

Zam
  • 2,880
  • 1
  • 18
  • 33
Dmitrij Holkin
  • 1,995
  • 3
  • 39
  • 86
  • make your `GetFromVbscript` variable `public`. – Mairaj Ahmad Jun 18 '15 at 11:56
  • @MairajAhmad -- Public? Can you show sample? it will not help (imho). when ASP preprocessor proceed ASP page it's proceed all ASP directive/command. JavaScript just including to output without any proceed. My opinion -- it's not possible. – Zam Jun 18 '15 at 12:02
  • yes i also tried this won't work i guess this will be only available in page. – Mairaj Ahmad Jun 18 '15 at 12:08
  • 1
    Please have a look at this http://stackoverflow.com/questions/10331740/access-c-sharp-variable-in-javasciprt-file-js – Mairaj Ahmad Jun 18 '15 at 12:13
  • "make Public Javascript variable", it's NOT the same as "public ASP variable". – Zam Jun 18 '15 at 12:31
  • You can also do like: <% Response.Write "" – cem Jun 19 '15 at 04:36

1 Answers1

1

It is an ugly way but you can put .js extension in IIS's "Handler Mappings" by putting executable as %windir%\system32\inetsrv\asp.dll.

cem
  • 1,535
  • 19
  • 25