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

  • Home
  • SEARCH
  • 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 6196825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:42:33+00:00 2026-05-24T03:42:33+00:00

I have an issue I have this jQuery code: $(document).ready(function(){ $(#follow).click(function(){ $.ajax({ type: ‘POST’,

  • 0

I have an issue I have this jQuery code:

    $(document).ready(function(){
        $("#follow").click(function(){
            $.ajax({
                type: 'POST',
                url:'/tweety-0.0.1-SNAPSHOT/twitter/tiles/follow',
                data:{
                        searchedUser: $('#searchedUser').val()
                }   
        })
    })
})

this piece of code get hidden id and send it’s value to the following method in my controller:

@RequestMapping(value="/follow",method=RequestMethod.POST)
    public @ResponseBody void followUser(@RequestParam("searchedUser") String userToFollow, 
            @ModelAttribute("user") User user) {
            if(userToFollow.equals(user.getUsername())){
                // do nothing
            }else{
                service.followUser(userToFollow,user.getUsername());
            }
    }

I want to send a session scoped attribute through the previous ajax call. Any clue on how doing that??

  • 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-05-24T03:42:35+00:00Added an answer on May 24, 2026 at 3:42 am

    Your best bet is to have that attribute’s value in a hidden input field somewhere on the page, so you can then read it in with jQuery.
    Unforunately, to the best of my knowledge jQuery or javascript does not have access to request, session or application scope variables.

    So, if you do something like this:

    <input type='hidden' name='${sessionVarName}' value='${sessionVarValue}' id='sessionVar'/>
    

    You can access it after the page loads like this:

    $(function(){
      var sessionVar = $('#sessionVar').val();
      alert(sessionVar);
    });
    

    This is the solution I’ve used when needing to get tomcat session vars into javascript, the method should work for you too.

    Hope this helps

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

Sidebar

Related Questions

I have embedded the fullcalendar jquery control by using this code: $(document).ready(function() { var
http://jsfiddle.net/yrM3H/2/ I have the following code: jQuery(document).ready(function() { jQuery(.toggle).next(.hidden).hide(); jQuery(.toggle).click(function() { $('.active').toggleClass('active').next('.hidden').slideToggle(300); $(this).toggleClass('active').next().slideToggle(fast); });
I have an issue with this jquery code below. Please give me advice or
I have the next code: $(document).ready(function () { $('#imgone').hide().delay(500).fadeIn(1000).delay(4500).fadeOut(500); $('#imgtwo').hide().delay(1500).fadeIn(1000).delay(3500).fadeOut(500); $('#imgthree').hide().delay(2500).fadeIn(1000).delay(2500).fadeOut(500); }); It's more
I have this strange issue with my web app. You see, I'm using jQuery
I have what seems to be a simple issue. I have a jquery function
I have an issue with jQuery and Safari (5.03). Hope this makes sense. I
I do not currently have this issue , but you never know, and thought
Ok so I've spent a couple hours trying to resolve this issue and have
Continuing my problem from yesterday, the Silverlight datagrid I have from this issue is

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.