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?

6
  • make your GetFromVbscript variable public. Commented Jun 18, 2015 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. Commented Jun 18, 2015 at 12:02
  • yes i also tried this won't work i guess this will be only available in page. Commented Jun 18, 2015 at 12:08
  • 1
    Please have a look at this stackoverflow.com/questions/10331740/… Commented Jun 18, 2015 at 12:13
  • "make Public Javascript variable", it's NOT the same as "public ASP variable". Commented Jun 18, 2015 at 12:31

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.