Tidak dapat menghantar data borang pada iOS Safari/Firefox
P粉520204081
P粉520204081 2024-04-04 12:53:48
0
1
509

Ini berfungsi pada semua platform kecuali Safari/Firefox pada iOS:

jQuery("#gform_1").one('submit', function(event) {
  const form = document.getElementById("gform_1");
  const firstName = document.getElementById('input_1_1').value;
  const lastName = document.getElementById('input_1_2').value;
  const phoneNumber = document.getElementById('input_1_3').value;
  const email = document.getElementById('input_1_4').value;

  const formData = {
    firstName: firstName,
    lastName: lastName,
    phoneNumber: phoneNumber,
    email: email
  };

  jQuery.ajax({
    url: 'https://www.example.com/submissions.php',
    type: 'POST',
    data: formData,
    success: function(response) {
      console.log("Success!", response);
    },
    error: function(xhr, status, error) {
      console.error("Error!", error);
      console.log(xhr.responseText);
    }
  });
});

console.error("错误!", error) kosong. Ia berkata "Ralat!". console.log(xhr.responseText) juga kosong. Saya tidak fikir ini adalah isu COR kerana Submits.php dihoskan pada pelayan/domain yang sama dengan borang.

P粉520204081
P粉520204081

membalas semua(1)
P粉340264283

Saya perlu menghalang Lalai.

jQuery("#gform_1").one('submit', async function(event) {
  event.preventDefault();
  const form = document.getElementById("gform_1");
  const firstName = document.getElementById('input_1_1').value;
  const lastName = document.getElementById('input_1_2').value;
  const phoneNumber = document.getElementById('input_1_3').value;
  const email = document.getElementById('input_1_4').value;

  const formData = {
    firstName: firstName,
    lastName: lastName,
    phoneNumber: phoneNumber,
    email: email
  };
  const request = await new Promise((resolve, reject) => {
    jQuery.ajax({
      url: 'https://www.example.com/submissions.php',
      type: 'POST',
      data: formData,
      success: function(response) {
        console.log("Success!", response);
        resolve();
      },
      error: function(xhr, status, error) {
        console.error("Error!", error);
        console.log(xhr.responseText);
        reject(error);
      }
    });
  });
  await request;
  console.log("AJAX request completed!");
});
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan