Question

Ajax call will only execute once, and then it's like ie caching the response and therefore my observables hold old values.

The code looks like this:

        $.ajax({
            url: "@Url.Action("GetInfo", "Info")",
            type: "GET",
            dataType: 'json',
            data: { id: newSelection },
            async: false,
            contentType: "application/json",
            success: function (response) {
                if (response.success) {
                    var array = [];
                    var existing = [];
                    $.each(response.data, function (index, value) {
                        array.push(value);
                        existing.push(value)
                    });


                    self.myObservable(array);
                    self.myObservable2(existing);

                } else {
                    alert(response.message);
                }
            }
        });
    });

How come that this code works perfectly in firefox and chrome but not ie?

Was it helpful?

Solution

Found the solution here

The problem is that IE automaticly caching ajax responses that use GET as method, while firefox and chrome doesn't.

My solution was to add cache: false in the ajax call.

OTHER TIPS

Have you tried using ko.cleanNode when leaving the page?

Example:

$(document).on("pagehide", function()
{
     ko.cleanNode(document);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top