jquery.post() processing flow
<p>I have a page that is posting a JSON to a cfc, and getting a success/fail message back. The array that the JSON is built from contains the ID's of the input fields that were updated.  I am changing the background color of the elements to alert the users that an update was made, but the problem arises when the the user posts more changes without leaving the page.  The array still contains the data from the previous post, and no matter what or where I try to clear the array, the changing of the background stops working.</p>

<p>Here is the code:</p>

<pre><code>$("input").change(function(){
    theArray.push({
       'id':$(this).attr('id'),
       'value':$(this).val()
    });

});

$("#edit_button").click(function(){
    if(theArray.length &gt;0){
        theArray.push({
           //some processing information to the cfc
        });
        theJson = JSON.stringify(theArray);
        $.post("CFCs/fund_profile.cfc",
            {
                method:"updateProfile",
                data:theJson
            },
            function(data){
            if(data.HASERROR == 1){
                $("#messageDiv").empty().html(data.MESSAGE);
            }
            else{
                $("#messageDiv").empty().html(data.MESSAGE);
                theArray.pop();//removing the cfc processing information
                for(var i = 0; i &lt;= theArray.length; i++){
                    var $el = $("#" = theArray[i].id).parent().parent().css('background','red');
                    setTimeout(function(){
                        $el.css('background','');
                        $("#messageDiv").empty();
                    },5000);
                }
            }
         },
         "json");
        //THIS IS WHERE THE PROBLEM LIES (I THINK)
        //I HAVE TRIED THE FOLLOWING:
        var arrayLen = theArray.length;
        for(var j = 0;j &lt;= arrayLen; j++){
            theArray.pop();
        }//DOESN'T WORK

        theArray.length = 0;
        //DOESN'T WORK

        for(var j = 0;j &lt;= arrayLen; j++){
            theArray.shift();
        }//DOESN'T WORK
    }
});
</code></pre>

<p>If I remove the code to clear the array, the background change happens, but the array never loses that element, and will always show that element as being updated.  If I keep it the background changes doesn't happen at all.</p>

<p>I"m sure it is something simple that I am missing, but I'm frustrated about it.</p>

<p>Any thoughts?</p>
