PDA

View Full Version : code not working in safari iphone and ipad



vinpkl
05-13-2015, 10:15 AM
Hi all

I am opening a popup on click of a button and there is a "add to cart" button in the popup which is adding the product to the cart.

Its working fine in all browsers except safari in iphone and ipad and mac desktop safari.

On safari the popup closes on click of "add to cart" button and product doesnt gets added to cart.



<form name="myform" id="myform" method="post">
<input type="hidden" value="<?php echo $id ?>" name="id" />
<input type="submit" value="ADD TO CART" name="qbutton" id="qbutton" />
</form>


javascript


<script type="text/javascript">
$(document).ready(function() {
$("#result").hide();
$("#qbutton").click(function() {
$("#result").show();
$("#result").html('Processing...');
$.ajax({
type: "POST",
url: "ajaxcart.php",
data: $("#myform").serialize(),
cache: false,
success: function(data) {
$("#result").html(data);
}
});
return false;
});
});
</script>


Thanks
Vineet

keyboard
05-13-2015, 10:20 AM
It may be an issue related to jQuery.
The click event isn't triggered by some mobile devices in some browsers.
Try this inplace of your current script (untested)


$(document).ready(function() {
$("#result").hide();
$("#qbutton").on("click touchstart", function() {
$("#result").show();
$("#result").html('Processing...');
$.ajax({
type: "POST",
url: "ajaxcart.php",
data: $("#myform").serialize(),
cache: false,
success: function(data) {
$("#result").html(data);
}
});
return false;
});
});

vinpkl
05-13-2015, 10:37 AM
Hi Keyboard

No This is also not working on safari iphone, ipad.

The popup closes on click of add to cart button.

Vineet

vinpkl
05-13-2015, 01:28 PM
Hi

Also can someone tell me how to update a "div" content that is on parent page on click of "add to cart" button.

Thanks
Vineet

Strangeplant
05-14-2015, 12:12 PM
The problem is with the ipad - it has a touch screen instead of a mouse, so a click never occurs, and the default behavior permits menu control by hover. Therefore, you have to make the element clickable. Add onclick="" to the element so the element knows its clickable; alternatively, you can define it so in css for that element as cursor: pointer;