user5068895 user5068895 - 11 days ago 6
Ajax Question

Ajax on Apple devices

Hi this code below works perfetcly in all device not apple.

I don't know why... Can you help me?

It works on desktop pc and on mobile Android, but not in Apple devices...

I have an ipad that i use To test but i don't know how can I debug my code on It...

$(document).on("touchstart click", "#btn", function(){

$(document).off("touchstart click", "#btn");

var data = $("#preview_form").serializeObject();

console.log(data);

$.ajax({

"type": "POST",
"url": ajaxurl,
"cache": false,
"data": data,
"beforeSend": function(){

$(".my-lightbox-close").click();
$("#wrapper").fadeOut();
$("#result").css({"min-height":"500px"}).html("<div id='loading-animation-container'><p><span id='glow'></span><span id='light'></span><span id='stars'></span><span id='stars-2'></span><span id='small-stars'></span><span id='small-stars-2'></span></p><div class='loader'><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--text'></div></div></div>");


},

"success": function (result) {
window.location.replace("http://www.example.com/");
return false;
},
"error": function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});

});


I Think that the ajax request is processed because my lightbox disappear on click. But data is not sent, and the page si not refreshed...

Answer

I have removed The Close Light box click And The ajax request was processed. It sound Strange But still works.

$(document).on("touchstart click", "#btn", function(){

$(document).off("touchstart click", "#btn");

var data = $("#preview_form").serializeObject();

console.log(data);

$.ajax({

    "type": "POST",
    "url":  ajaxurl,
    "cache": false,
    "data": data,
    "beforeSend": function(){

        //$(".my-lightbox-close").click();
        $("#wrapper").fadeOut();
        $("#result").css({"min-height":"500px"}).html("<div id='loading-animation-container'><p><span id='glow'></span><span id='light'></span><span id='stars'></span><span id='stars-2'></span><span id='small-stars'></span><span id='small-stars-2'></span></p><div class='loader'><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--dot'></div><div class='loader--text'></div></div></div>");


    },

    "success": function (result) {
                  window.location.replace("http://www.example.com/");
        return false;
    },
    "error": function (xhr, ajaxOptions, thrownError) {
        alert(xhr.status);
        alert(thrownError);
    }
});

});

Comments