Q:

Multiple call from same javascript function with ajax, object in parameters not the same between the function body and the ajax success callback

I've got a strange result when I called my javascript method with ajax. When the user click on an arrow, it load the data, I don't want the user to be stuck so I let him change when he want. And when the data come back from the server, I want to load the data at the good object in my collection.
html like that ( a little more complex than that but hard to paste and I think it's enough to understand) :
  <a href='#' data-bind='click:LoadExactResult'>Next</a>

js:
 function LoadExactResult(dateObj) {
    //method body
    (function(dateObj) {
        var payload = {
            searchCriteriaParam: "",
        };

        console.log(moment() + " - Calling Exact Date: " + dateObj().Date());
        dateObj().IsAllFlightLoading(true);
        $.ajax({
            url: 'bla/bla',
            data: payload,
            cache: false,
            success: function(result) {
                console.log(moment() + " - Exact Date Success: " + dateObj().Date());
                // ajax body.
            }
        });
    })(dateObj);
}

But the data always come back for the last loaded object... Here is the console log.

1410377364469 - Calling Exact Date: Mon Jan 05 2015 22:00:00 GMT-0500 (Est) 
1410377365234 - Calling Exact Date: Sun Jan 04 2015 21:10:00 GMT-0500 (Est) 
1410377365539 - Calling Exact Date: Sat Jan 03 2015 20:40:00 GMT-0500 (Est) 
1410377367559 - Exact Date Success: Sat Jan 03 2015 20:40:00 GMT-0500 (Est) 
1410377370488 - Exact Date Success: Sat Jan 03 2015 20:40:00 GMT-0500 (Est) 
1410377375648 - Exact Date Success: Sat Jan 03 2015 20:40:00 GMT-0500 (Est)

A:

The problem was related to the fact that dateObj was an observable from knockout and each time I was calling dateObj(). It was recalculating the value. I had to pass not a knockout observable to the function LoadExactResult, but a real object
function LoadExactResult(dateObj) {
    //method body
        var payload = {
            searchCriteriaParam: "",
        };

        console.log(moment() + " - Calling Exact Date: " + dateObj.Date());
        dateObj.IsAllFlightLoading(true);
        $.ajax({
            url: 'bla/bla',
            data: payload,
            cache: false,
            success: function(result) {
                console.log(moment() + " - Exact Date Success: " + dateObj.Date());
                // ajax body.
            }
        });
}

