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 8739791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:00:36+00:00 2026-06-13T11:00:36+00:00

I have 8 search filters user can choose. When user clicks on filter it

  • 0

I have 8 search filters user can choose. When user clicks on filter it opens options for this filter. When user clicks out, the function hideFilterSearch() is triggered. I have problem about understanding of scope for variable formData (see below).

$(document).ready(function() {
    var formData = $("form").serialize();
});

function hideFilterSearch() {
    console.log(formData);
    $(".filters").hide();
    newFormData = $("form").serialize();
    if (formData != newFormData) {
        //newFormData is sent with ajax and search results are updates
    }
    formData = $("form").serialize();  
}

//show, hide filter changer
$('body').click(function(event) {
    if (!$(event.target).closest('.filter').length) {        
        hideFilterChanger();
    };
});

Console log gives me empty string in this case. I tried also to send formData as argument ()hideFilterSearch(formData), but then the problem is formData won’t be updated. I am not sure what is the correct way to pass formData to function, but still update it’s value inside function when it is changed.

  • 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-13T11:00:37+00:00Added an answer on June 13, 2026 at 11:00 am

    Use global variable.As formData variable in local scope,you can’t accesss it in antother function.

    Change your code to the following

    window.formData = $("form").serialize();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox where the user can specified the filters of one search:
I have search through the web to figure this out but no luck. I
I have created a search page uising exposed filters and views module. The user
I'm implementing a faceted search functionality where the user can filter and drill down
I have a search table where user will be able to filter results with
I have a search form with filters. 1 filter is range which is to
The big picture: I'm working on a search form where the user can choose
I currently have multiple search fields within one form which the user can pick
I have a search page and want to add some filters to it, my
i have search at this websit : https://stackoverflow.com/search?page=2&tab=relevance&q=nsarraym%20objectatindex%20index%205%20beyond%20bounds%20for%20empty%20array%27 but the solve no suit me.

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.