Ask confirmation to user (through jQuery) before ajax post >> strange behaviour
<p>I have a strange behaviour in my ajax posting. First, I display an anchor link with the class 'remove-link'. From this link, I get the target URL in the variable removeLinkObj. Next, I show a jquery ui dialog to ask the user to confirm. Then I do the ajax call with the url removeLinkObj. </p>

<p>The problem is that in STEP1 the link is (for example) ../../43 and in STEP2 the link is ../../42. So it is the previous value! Why is the value not the right one? I don't know if I'm clear?</p>

<p>The aim of my code is to ask confirmation to the user (through a jquery ui dialog) before posting.</p>

<pre><code>$().ready(function () {

var removeLinkObj;

$('.remove-link').click(function () {
    // STEP1
    removeLinkObj = $(this);  //for future use
    $('#confirm-remove').dialog('open');
    return false; // prevents the default behaviour
});

$('#confirm-remove').dialog({
    autoOpen: false, width: 500, resizable: false, modal: true,
    buttons: {
        "Continue": function () {
            // STEP2
            $.ajax({
                type: "Delete",
                url: removeLinkObj[0].href,
                cache: false,
                success: function (data) {
                    alert(data.TransportedMaterialId);
                    $("#" + data.TransportedMaterialId).remove();
                }
            });
            $(this).dialog("close");
        },
        "Cancel": function () {
            alert('User clicked Cancel');
            $(this).dialog("close");
        }
    }
});

})
</code></pre>

<p>And in my html:</p>

<pre><code>&lt;a href="aa/bb/44" class="remove-link"&gt;Delete&lt;/a&gt;
</code></pre>

<p>Thank you anyway.</p>
