parseJSON is not working on iPad safari Browser

parseJSON is not working on iPad safari Browser
150 Views

Specifically what you are looking at is the jQuery code.

<div class="cxc-json-parse-html">
		{"id":1,"title":"iPhone 9","description":"An apple mobile which is nothing like apple","price":549,"discountPercentage":12.96,"rating":4.69,"stock":94,"brand":"Apple","category":"smartphones","thumbnail":"/data/products/1/thumbnail.jpg","name":"Test","age":35,"city":"Canada"}
</div>
	<script type="text/javascript">
		jQuery(document).ready(function() {
			var cxc_html = jQuery('.cxc-json-parse-html').html();
			var obj = JSON.parse( cxc_html ); // You Can Access This jQuery.parseJSON( cxc_html );
			console.log(cxc_html); 
		});
	</script>

The JSON data is OK, however when strings that resemble dates or strings are included within an HTML node, both the iPad and iPhone produce clickable links. So, basically, when you put your JSON into a regular HTML DOM node, it gets distorted.

This code will begin to function when you include these meta tags in your page header. There are various meta tags that should work to remedy this; you may have to experiment to see which ones work best for you.

	<meta name="format-detection" content="telephone=no">
	<meta name="format-detection" content="date=no">
	<meta name="format-detection" content="address=no">

Was this article helpful?
YesNo

Leave a comment

Your email address will not be published.