Jquery val() does not recheck / reevaluate the value
<p>short description 
I'm using jquery, jqueryUI and ajax.</p>

<p>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.</p>

<p>Long descriptionn 
I'm developing a big project I have ~2 years on this project 
My head is pumping! ;)</p>

<p>I have something like this :</p>

<p>this is the html for the div :</p>

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

<p>this is the script :</p>

<pre><code>&lt;script&gt;
$(".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();
});​
&lt;/script&gt;
</code></pre>

<p>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.</p>

<p>I don't want to use location.reload() </p>

<p>this file is 1700+ lines long but this is the part where the problem is.</p>

<p>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.</p>

<p>Thank for helping I hope this is stupid or easy one .</p>
