javascript - Is it possible to have two success callback functions with a jQuery.post()? -


is possible?

once jquery.post successfull instead of having 1 success callback have two.

for example

once form has posted data empty div called "#msg" given style , content and empty div called "colour-block" given style.

code far

$('#form1').submit(function(e) { e.preventdefault();  $.ajax({      type: 'post',      url: 'indextest1.php',      data: $("#form1").serialize(),      success: function(response) {  $('#msg').html("<div style='border: 1px solid black; padding:15px 50px 15px 20px; width:437px; border-radius: 8px; background:#d3edd3 url(img/accepted_48.png) no-repeat 450px center;'>now sit , relax.....</div>");       }    }); }); 

any or pointers appreciated.

things i've tried , have not worked!

adding callback

$('#form1').submit(function(e) { e.preventdefault();  $.ajax({      type: 'post',      url: 'indextest1.php',      data: $("#form1").serialize(),      success: function(response) {    $('#msg').html("<div style='border: 1px solid black; padding:15px 50px 15px 20px; width:437px; border-radius: 8px; background:#d3edd3 url(img/accepted_48.png) no-repeat 450px center;'>now sit , relax</div>");   $("#colour-block").html("<div style='border: 1px solid black; padding:15px 50px 15px 20px; width:437px; border-radius: 8px; background:#d3edd3 url(img/accepted_48.png) no-repeat 450px center;'>bla bla</div>");      }    }); }); 

using promise interface

$('#form1').submit(function(e) { e.preventdefault();   var ajax = $.ajax({         type : 'post',         url  : 'indextest1.php',         data : $("#form1").serialize()     }).done(function(response) {   $("#msg").html('<div style='border: 1px solid black; padding:15px 50px 15px 20px; width:437px; border-radius: 8px; background:#d3edd3 url(img/accepted_48.png) no-repeat 450px center;'>now sit , relax while go work on behalf, we\'ll keep updated information on our results , if have questions welcome calls or emails on 078675675446 or isaaclayne@southwestcarfinder.co.uk</div>');   $("#colour-block").html('<div style='border: 1px solid black; padding:15px 50px 15px 20px; width:437px; border-radius: 8px; background:#d3edd3 url(img/accepted_48.png) no-repeat 450px center;'>now sit , relax while go work on behalf, we\'ll keep updated information on our results , if have questions welcome calls or emails on 078675675446 or isaaclayne@southwestcarfinder.co.uk</div>');      });    }); }); 

just both:

$('#form1').submit(function(e) { e.preventdefault();  $.ajax({      type: 'post',      url: 'indextest1.php',      data: $("#form1").serialize(),      success: function(response) {          $('#msg').html("<div style='border: 1px solid black; padding:15px 50px 15px 20px; width:437px; border-radius: 8px; background:#d3edd3 url(img/accepted_48.png) no-repeat 450px center;'>now sit , relax.....</div>");          $('.colour-block').css({/*css styles here*/});      }    }); }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -