Jquery在成功或完成时单击触发器

时间:2013-12-28 08:08:52

标签: javascript php jquery

我正在尝试获取提交按钮上的另一个功能,即。 class =“sucessClass”在成功或完成时执行。这是我的代码:

$(document).ready(function() {

$("#send").on("click", function(){

    var name=$("#name").val
    var email=$("#email").val   
    var message=$("#message").val
    var dataString="name=" + name + "&email=" + email + "&message=" message;

        $.ajax({
        type: "POST",
        url: "proData.php",
        data: dataStringxx,
        success: function(html){

            |=== sucess function ===|

        }
         else{

        }
}
});


    
    Name :
    Email : 
    Message : 
    Send
    

1 个答案:

答案 0 :(得分:2)

您可以尝试类似

的内容
$(document).ready(function() {

    $("#send").on("click", function(){

        var name=$("#name").val();
        var email=$("#email").val();   
        var message=$("#message").val();
        var dataString="name=" + name + "&email=" + email + "&message=" message;

        $.ajax({
            type: "POST",
            url: "proData.php",
            data: dataStringxx,
            success: function(html){
              $('.successClass').trigger('click');   
            }

        });
   });

   $('.successClass').click( function(){
      // write your code here what needs to be done.
   });

});