javascript/AJAX 无法在 safari 中工作,无法冒泡到正文

标签 javascript php jquery ajax safari

我有一个 php/javascript/ajax 代码,允许添加、更新和删除记录,在我的笔记本电脑上一切正常。如果我尝试在手机上使用它,添加和删除记录可以工作,但更新不行。为了更新记录,需要移动 div 以使下面的表单框可见。我认为我在点击和模糊事件处理程序方面遇到了麻烦。我对 Javascript 很陌生,并且看过一些有关使用控制台查找错误的教程,但我不知道从哪里开始。我认为导致问题的代码部分是:

// Show the text box on click
    $('body').delegate('.editable', 'click', function(){
        var ThisElement = $(this);
        ThisElement.find('span').hide();
        ThisElement.find('.gridder_input').show().focus();
    });

一旦这个问题得到解决,我担心以下问题也可能会持续存在:

// Pass and save the textbox values on blur function
    $('body').delegate('.gridder_input', 'blur', function(){
        var ThisElement = $(this);
        ThisElement.hide();
        ThisElement.prev('span').show().html($(this).val()).prop('title', $(this).val());
        var UrlToPass = 'action=update&value='+ThisElement.val()+'&crypto='+ThisElement.prop('name');
        if(ThisElement.hasClass('datepicker')) {
            return false;
        }
        $.ajax({
            url : 'activities_ajax.php',
            type : 'POST',
            data : UrlToPass
        });

最佳答案

终于找到答案了。它只是委托(delegate)给了不起作用的主体,因此我在所有内容周围添加了一个 div 包装器并委托(delegate)给它而不是主体。

关于javascript/AJAX 无法在 safari 中工作,无法冒泡到正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29565714/

相关文章:

javascript - 使用 ForEach 将数据绑定(bind)到表

javascript - 在Javascript中找到单词中重复字母的最大数量

php - 使用 for() 循环创建唯一的 PHP 变量

jquery - jQuery 中的 Foreach

javascript - 根据ajax json响应更新html表

javascript - 将列表拆分为两列。列表没有 block ,但需要在最近的 <p> 标签上拆分

javascript - 如何修复VueJS中的 "this is undefined"?

javascript - 颜色图标到悬停位置

php - jQuery 无法检索数据库更新

php - 使用 PHP 中的对象后是否需要销毁它们?