答案 0 :(得分:0)
所以我在window.onbeforeunload事件上这样做。感谢madalin和this回答。
<script type="text/javascript">
window.onbeforeunload = function (e) {
var dataItems = [...];
var model = JSON.stringify({ 'model': dataItems });
$.ajax({
url: "@Url.Action("SaveDefaultSettings", "Maps")",
type: 'get',
data: { defaultSettings: model },
success: function (data) {
}
});
};
</script>