0

I have an AJAX code that's working on all browser the way it's supposed to but not working on iOS safari. On iOS safari it doesn't call the success: function and goes directly to error: function. Why is this happening.

On further exploring the data: cartData on iOS safari comes out to be quantity=1&id=<a href="tel:33217807108">33217807108</a> instead of just quantity=1&id=33217807108.

Here is the code:

  $.ajax({

    type: 'POST',
    url: '/cart/add.js',
    data: cartData,
    dataType: 'json',
    cache: false,
    headers: { "cache-control": "no-cache" },

    success: function(cartData){

      if(product == 1){
        if(cartCounter == (noItems - 1)){
          // console.log('update');
          updateCart();
        }else{
          // console.log('add to cart');
          cartCounter++;
          cartAdd(productType,1);

        }
      }else{

        // console.log('update 2')
        updateCart();

      }
    },
    error: function(response){
        alert(response);        
    }
  });

}

1 Answers1

0

try adding this to your header:

<meta name="format-detection" content="telephone=no">
Nosajimiki
  • 1,073
  • 1
  • 9
  • 17
  • Doesn't work. Not sure how this will work for data: cartData – Sam JS guy Nov 01 '18 at 19:12
  • A common work around for this sort of thing is to append extra data to the number to make it look less like a phone number. So, you could try to make it something like ID=3321A7807A108, and then then remove 'A's in your add.js or something like that – Nosajimiki Nov 01 '18 at 20:46