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?

Était-ce utile?

La 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.

Autres conseils

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

Example:

$(document).on("pagehide", function()
{
     ko.cleanNode(document);
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top