我通過Ajax發送訂單到電子郵件。所有瀏覽器都能正常工作接受Safari,因爲我看到它緩存了請求和響應中的數據。我怎麼能解決這個問題。因爲在Safari中表單隻在清除緩存後才發送。防止緩存Ajax
$('#form-constructor').submit(function() {
var form_data = $(this).serialize();
$.ajax({
type: "POST",
url: "data/constructor.php",
data: form_data,
cache: false,
success: function() {
document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
window.onpageshow = function (event) {
if (event.persisted) {window.location.reload();}};
[jQuery的AJAX調用結果防止瀏覽器緩存(可能的重複https://stackoverflow.com/questions/367786/prevent-browser-caching-of -jquery-ajax-call-result) –