Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8754835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:43:08+00:00 2026-06-13T13:43:08+00:00

I have simple code in GoogleOauth2.js file function storedAccsessToken(token) { $.ajax({ type: GET, url:

  • 0

I have simple code in GoogleOauth2.js file

function storedAccsessToken(token) {
    $.ajax({
        type: "GET",
        url: '<%=HttpContext.Current.Request.ApplicationPath %>/SaveToken.ashx?accToken=' + token,
        dataType: "text",
        complete: function (resp, status) {
            if (status == "success" || status == "notmodified") {
                if (resp.responseText != '');
                alert(resp.responseText);
                window.location = window.location;

            }
        }

    });

}

and

function refresh() {
    var akkToken = '<%=Session["googleAccToken"]%>';
    $.ajax({
        url: 'https://www.googleapis.com/oauth2/v1/userinfo?access_token=' + akkToken,
        data: null,
        success: function (resp) {
            user = resp;
            alert(user.name);
        },
        dataType: "jsonp"
    });

}

when i put js file in teg head

<head runat="server">
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
    <script src="Scripts/GoogleOauth2.js" type="text/javascript"></script>

</head>

and when i start my project and debug js i see that <%=Session[“googleAccToken”]%>
compilator understand this as text
but when i put js code in head tag between simple <script type="text/javascript"></script> it work fine and i get my value in session i want to know can i keep this code
in separate file and that it worked fine

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:43:09+00:00Added an answer on June 13, 2026 at 1:43 pm

    Your error is that you have include the <%= %> inside the javascript .js files, and they are not compile to give the results you expect – they stay as they are.

    There are two possible solutions to that.
    Ether include the variables before the javascript file, ether full move it to the page so the <%= %> can be compile. For example, you can do that :

    <head runat="server">
        <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
        <script>
           var akkToken = '<%=Session["googleAccToken"]%>';
           var UrlTo = '<%=HttpContext.Current.Request.ApplicationPath %>SaveToken.ashx?accToken=';
        </script>
        <script src="Scripts/GoogleOauth2.js" type="text/javascript"></script>
    </head>
    

    and remove the akkToken from the GoogleOauth2.js file, and place url:UrlTo + token on the other line that also have the <%= %>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple code: <html> <head> <script src=jquery-1.5.1.min.js type=text/javascript></script> <script type=text/javascript> $(function() {
I have simple code that does a head request for a URL and then
I have this simple code here, nothing too advanced. $(input#send).submit(function(event){ event.preventDefault(); $.ajax({ type: 'POST',
I have a simple code that gets xml file from given URL: DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(link); that
I have this simple code where I am sending http request and reading all
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have simple JavaScript code that is using the Ajax API for fetching a
I have simple HTML code: <input type='hidden' name='cat_id' value='123'/> <a href='#' class='edit'>Edit</a> <a href='#'
i have this simple code i just can't get it working. <html> <head> <script
I have simple code to draw in canvas element: function doFirst(){ var x =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.