独立的jquery函数在被调用时连续执行


Independent jquery functions execute consecutively when one is called

我的问题似乎很基本,但我尝试了很多不同的方法将这些功能放在一个html文件中,但都无济于事。问题是,当第一个函数被调用时,第二个函数也在运行,这就给我留下了第二个函数的结果。我不知道我做错了什么,请帮助。下面是有问题的代码

<script>
$(document).ready(function () { // Make sure the elements are loaded on the page
    // Listen for a click event on the button
    $('#buttonON').click(funct);
    $('#buttonOFF').click(funct2);  
});
// Now define the function
function favfunct(e) {
    // Stop the page from "following" the button (ie. submitting the form)
    e.preventDefault();
    e.stopPropagation();
    // Insert AJAX call here...
        $.ajax("carstatusupd.php", {
        // Pass our data to the server
        data: { "username" : "sibusiso", "caron" : "1", "caroff" : "0"},
        // Pass using the appropriate method
        method: "POST",
        // When the request is completed and successful, run this code.
        success: function (response) {
                // Successfully added to favorites. JS code goes here for this condition.
            }
    });
function funct2(e) {
    // Stop the page from "following" the button (ie. submitting the form)
    e.preventDefault();
    e.stopPropagation();
    // Insert AJAX call here...
    $.ajax("carstatusupd.php", {
        // Pass our data to the server
        data: { "username" : "sibusiso", "caron" : "0", "caroff" : "1"},
        // Pass using the appropriate method
        method: "POST",
        // When the request is completed and successful, run this code.
        success: function (response) {
                // Successfully added to favorites. JS code goes here for this condition.
            }
    });
}
</script>

函数favfunct()中省略了右括号

 Please use this,
 <script>
 $(document).ready(function () { 
       function funOne(){
        };
       function funTwo(){
        };

    $('#buttonON').live('click',function(){
        funOne();
    });
    $('#buttonOFF').live('click',function(){
       funTwo();        
    });
 });

 NOte: initialize function before use and initialize them into document ready.