AJAX浏览器问题

For some reason I'm having weird problems getting AJAX to work properly across the different web browsers. Is there anything in particular that is necessary, or any trick to get things to work smoothly across them?

The first issue I am having is with the following, it works perfect in Chrome, but does nothing at all in ie and firefox:

function DeleteRideshare(pid){
    if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    }
    else{// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }           
    // Verify
    var conf = confirm("Are you sure you want to delete this rideshare?");
    if(conf == true){
        xmlhttp.open("POST","updaterideshare.php",true);
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xmlhttp.send("delete=true&PostID="+pid);    
        location.reload();                      
    }           
}   

I also have this, which works with some elements in chrome, and not at all in ie and firefox:

$(document).ready(function(){
    $("#EditRideshareAjax").submit(function(){
        // Stop the from from submiting normally
        event.preventDefault();         

        // get the values from the elements on the page
        var values = $(this).serialize();

        $.ajax({
            type: "POST",
            url: "updaterideshare.php",
            data: values,
            success:     function(msg){                                         
                location.reload();
            },
            error:function(){
                alert("An error has occured, please try again");
            }
         });
    });
});

Any help or insight would be greatly appreciated! Thanks!

Do not you have to pass event as argument in the function and then use it.

           $("#EditRideshareAjax").submit(function(event){