dongzhun8449 2010-06-10 15:50
浏览 87

需要有关Safari / Mac中jQuery / AJAX调用的帮助

I've got something that works perfectly in FF and MSIE but it's not working properly in Safari. It's a form with selects that get updated via AJAX/jQuery from a MySQL DB.

In Safari, when you select the first item, it correctly loads the options for the next select menu; however, when you choose one of those (which loads new options in a subsequent select menu), the whole form resets and is broken from that point on. Does anyone know of a Safari bug that would cause this? Here's the JS:

$(document).ready(function(){
    $("#searchForm select").change(updateSearchForm);
});
function updateSearchForm() {
    $.ajax({
        url: '/elements/search_form.php?ajax=true',
        data: $('#searchForm').serialize(),
        error:function(xhr,err){
            alert("readyState: "+xhr.readyState+"
status: "+xhr.status);
            alert("responseText: "+xhr.responseText);
        },
        success: function(data) {
            $("#searchForm").html(data);
            $("#searchForm select").change(updateSearchForm);
        }
    });
}

I can post the relevant PHP/HTML for the form, but it's lengthy. I'm relatively new to JS so I'm not sure where to start debugging this... TIA

  • 写回答

2条回答 默认 最新

  • dpg98445 2010-06-11 20:07
    关注

    Could be you are creating an invalid form by replacing the HTML. Some browsers are quite picky about this. Of course I dont know for sure because you did not send the whole code but have you tried to modify the form using append() instead of html() ? Also try to append a small portion first just for diagnostic reasons.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题