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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:51:21+00:00 2026-06-12T05:51:21+00:00

short description I’m using jquery, jqueryUI and ajax. I use val() to get value

  • 0

short description
I’m using jquery, jqueryUI and ajax.

I use val() to get value from a field the first time it does it perfectly
but if I change the value in the field the value stay the same.

Long descriptionn
I’m developing a big project I have ~2 years on this project
My head is pumping! 😉

I have something like this :

this is the html for the div :

<div id="add_task_diag" style="display: none">
   <label for="task">Task : </label><input id="taskfrm" label="Task" value="task" name="taskval" placeholder="e.g fill in tax form" />
   <button value="submit" class="btn btn-large add_task_frm">Add task</button> <button class="btn btn-large cancel_add_task">Cancel</button>
</div>
<button class="btn btn-primary" id="add_task"><i class="icon-file icon-white"></i> Add Todo</button>

this is the script :

<script>
$(".add_task_frm").click(function() {
    function taskgen() {
        var data = "task=" + $("#taskfrm").val();
        alert(data); // only for debuging
        var task_data = data;
        alert(task_data); // only for debuging
        $.post("whereitneedtogo.php?task=action80", task_data), //this is the ajax part
        $("#add_task_diag").dialog("destroy"); // I had here close I changed it to "destroy"
        task_data = undefined; //I tried to unset the variable
    }
    taskgen();
});​
</script>

When I run it everything work fine! when I resend with another value the variable stays the same. e.g if I put test123 in the field in the seccond test it will stay test123
I need to reload the page to reset the variable.

I don’t want to use location.reload()

this file is 1700+ lines long but this is the part where the problem is.

I tried alot of things like :
– setting my script after Dom is ready
– setting my variables to undefined or null
– destroy the jquery tabs
– the only part seems to be working for me is location.reload but my application is full ajax.

Thank for helping I hope this is stupid or easy one .

  • 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-12T05:51:22+00:00Added an answer on June 12, 2026 at 5:51 am

    Why are you trying to declare and call the function every time you click.. Try moving it outside the click event handler..

    <script>
    $(".add_task_frm").click(function() {
        taskgen();
    });​
    
    function taskgen() {
            var data = "task=" + $("#taskfrm").val();
            alert(data); // only for debuging
            var task_data = data;
            alert(task_data); // only for debuging
            $.post("whereitneedtogo.php?task=action80", task_data), //this is the ajax part
            $("#add_task_diag").dialog("destroy"); // I had here close I changed it to "destroy"
            task_data = undefined; //I tried to unset the variable
        }
    
    </script>
    

    You might also encounter scoping issues when you want to call the taskgen() from some other place..

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

Sidebar

Related Questions

I have a table with films. There is a field with short description. Using
First, a short description of the problem's background: I've run into troubles with handling
Short Description I am using charts for a specific application where i need to
Short Description The question is not meant to ask if using virtual environments are
First - a short description of a problem. I write a JavaScript function to
Short description of the page: user searches for an account (first form is to
So far, I haven't figured out how to retrieve the short description paragraph from
i want to remove some fields like description,short description from catalog->Manage Products->continue->general tab in
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
I need to display short description like label and near it data associated with

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.