Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

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

Example:

$(document).on("pagehide", function()
{
     ko.cleanNode(document);
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top