Need help with jQuery/AJAX call in Safari/Mac

Posted by protohominid on Stack Overflow See other posts from Stack Overflow or by protohominid
Published on 2010-06-10T15:50:13Z Indexed on 2010/06/13 13:12 UTC
Read the original article Hit count: 218

Filed under:
|
|
|
|

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+"\nstatus: "+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

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript