$.post issue in Jquery specific scenario
<p>Let me share my jQuery part first </p>

<pre><code>$(".btnUpdateInput").click(function() {
            //alert("Update");
            var BldDocumentId = $("#BldDocId").val();

            var BldinstructionId = $("#BldIPInstnId").val();
            var InputFieldId = $("#InputFieldId").val();
            var InputFieldValue = jQuery.trim($(this).parent().prev().text()); //$("#InputFieldValue").val();
            var InputFieldUserValue = jQuery.trim($(this).prev().val()); // $(".user_input_value").val();
            alert(BldDocumentId + "," + BldinstructionId + "," + InputFieldId + "," + InputFieldValue + "," + InputFieldUserValue);

            var postResult;
            alert($(this).get());
            $.post("/Build/UpdateInputField",
                { bldDocId: BldDocumentId, bldInstnId: BldinstructionId, inputFieldId: InputFieldId, inputFieldValue: InputFieldValue, inputFieldUserValue: InputFieldUserValue },
                function(result) {
                postResult = result;
                    //Either this should function**
                    alert($(this).get()); // returned Object[Object] but expected the clicked button
                    alert($(this).parent().get());// returned null
                    alert($(this).parent().next().get());//returned null
                    alert($(this).parent().next().children().first().get());// returned null

                    // $(this).parent().next().show();
                    // $(this).parent().next().children().first().text(InputFieldUserValue);
                    // $(this).parent().hide();
                });

                alert(postResult);
            //Or this should function**
            if (postResult == true) {
                $(this).parent().next().show();
                $(this).parent().next().children().first().text(InputFieldUserValue);
                $(this).parent().hide();
            }
        });
</code></pre>

<p>Now let me explain my issue. I need to show and hide few divs with respect to the button "btnUpdateInput" I clicked. I tried it in two ways: 1. I gave the following lines in the in the success part of $.post </p>

<pre><code>$.post("/Build/UpdateInputField",
                { bldDocId: BldDocumentId, bldInstnId: BldinstructionId, inputFieldId: InputFieldId, inputFieldValue: InputFieldValue, inputFieldUserValue: InputFieldUserValue },
                function(result) {
                postResult = result;
                    //Either this should function**
                    alert($(this).get()); // returned Object[Object] but expected the clicked button
                    alert($(this).parent().get());// returned null
                    alert($(this).parent().next().get());//returned null
                    alert($(this).parent().next().children().first().get());// returned null

                    // $(this).parent().next().show();
                    // $(this).parent().next().children().first().text(InputFieldUserValue);
                    // $(this).parent().hide();
                });
</code></pre>

<p>2. or get the value of postResult out and compare and do the same there. The code is bellow: </p>

<pre><code> if (postResult == true) {
                $(this).parent().next().show();
                $(this).parent().next().children().first().text(InputFieldUserValue);
                $(this).parent().hide();
            }
</code></pre>

<p>Neither works for me. In 1 am not getting $(this) as the button 'btnUpdateInput' that i click and 2. the value of postResult is undefined since there is no delay so that postResult is assigned to result of post action.</p>

<p>Please help me out with either of the scenario.</p>
