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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:21:36+00:00 2026-05-17T16:21:36+00:00

I’m doing my first web app (not new to programing) and I have a

  • 0

I’m doing my first web app (not new to programing) and I have a little problem that I know why I have it but I need a way to sort it out.

I make an ajax post on a page, that ajax post uses two hidden fields to retrieve some data, send it to the Action and get some json to show up. Perfect.

The thing is that I’m changing the content of the page with that ajax post. Its just a calendar and I have a link to move between months. I use 2 hidden fields to keep track of month and year (I use that 2 values to pass to the action and change the month).

My problem is that when I click the link, the month changes (my code is OK with that) but the DOM is still the old one.

The problem is that I use 2 hidden fields to keep track of actual month / year because I need that values on jQuery (it seems that if I need to use my Model data with jQuery I have to save it on hidden values and retrieve it later). When I change the month via ajax I expect the 2 hidden fields to update their value…

<input id="curMon" type="hidden" value="<%: Model.Month %>" />
<input id="curYear" type="hidden" value="<%: Model.Year %>" />

…With the new month data.

I know that when you do an ajax post, the DOM is still the old one. I tried with livequery:

$("#forward").live("click", function () {                

            $.post($(this).attr("href"), function (response) {
                $("#calendar").replaceWith($(response).filter("div#calendar"));
                loadDays(currentMonth);
            });
            return false;
        });

forward is the link. Calendar is the div containing the calendar and the two hidden fields. loadDays just get some json to change things on the calendar.

currentMonth is:

        var month = $("#curMon").val();
        var year = $("#curYear").val();

        var currentMonth = { Month: month, Year: year };

Well, I need that when I change the month via ajax, I can get the new values from the hidden field instead the old one.

Is there a way to do it or I’m doing this the hard way?

  • 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-17T16:21:36+00:00Added an answer on May 17, 2026 at 4:21 pm

    It looks like you’re not updating the value of your month and year variables, try just assigning the selectors to the variables so you can update currentMonth.

        var month = $("#curMon");
        var year = $("#curYear");
    
        var currentMonth = { Month: month.val(), Year: year.val() };
    

    Current month needs to be re-assigned in the live portion of the code, or you can just do this

        $("#forward").live("click", function () {                
    
            $.post($(this).attr("href"), function (response) {
                $("#calendar").replaceWith($(response).filter("div#calendar"));
                loadDays({Month: $("#curMon").val(), Year: $("#curYear").val() });
            });
            return false;
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.