Jquery click trigger on Success or Complete

oxEgen Source

I am trying to get another function that is on submit button ie. class="sucessClass" to be executed on success or complete. Here are my codes :

$(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
    
javascriptphpjquery

Answers

answered 4 years ago Abhik Chakraborty #1

You can try something like

$(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.
   });

});

comments powered by Disqus