PDA

View Full Version : trigger after previous function finish



ggalan
06-16-2011, 07:21 PM
what is the best way to trigger a ajax call after the post happens?
this is what i have


function ajaxCall(name, prodid){
$.ajax({
type: "POST",
url: "shortList.php",
data: ({'name':name, 'prodid':prodid }),
success: function(msg){
$('#listColumn').html(msg);
}
});
}

$("#output a").click(function () {

var name = $(this).text();
var prodid = $("#prodid").val();

$.post("class/i.Name.php", { name: name, prodid: prodid },
function(data){
$("#listColumn").html(data);
});

ajaxCall(name, prodid);// trigger this after all the above is done

});

jscheuer1
06-16-2011, 08:45 PM
I may have misunderstood the question, if so pleas clarify. But how about just moving it into the callback for the post:


function ajaxCall(name, prodid){
$.ajax({
type: "POST",
url: "shortList.php",
data: ({'name':name, 'prodid':prodid }),
success: function(msg){
$('#listColumn').html(msg);
}
});
}

$("#output a").click(function () {

var name = $(this).text();
var prodid = $("#prodid").val();

$.post("class/i.Name.php", { name: name, prodid: prodid },
function(data){
$("#listColumn").html(data);
ajaxCall(name, prodid);// trigger this after all the above is done
});

});

ggalan
06-16-2011, 09:42 PM
yes, that did it!
btw, how do you highlight yellow inside [code] ?

jscheuer1
06-17-2011, 01:37 AM
Using the mouse and/or keyboard select the text you want highlighted. Then click on the #i icon on the editor (toward the top, somewhat to the right). It will surround the selected text with:

This would be highlighted but for some clever use of the text color utility to make the tags appear as normal text.

tags and thereby highlight it. You can also do it outside of a code block. Or you may if you wish type the tags manually.

Inside a tag block it will only work for the
and
tags, the HTML and PHP code blocks have syntax highlighting so ignore formatting tags within their borders.