Im using jquery and am trying to make some function to fire after each other. DOes the following seems right. I'm pretty much calling a function in a function.
$j = jQuery.noConflict();
var obj;
var items = new Array();
$j(document).ready(function() {
function setTopicsSpans() {
// do stuff
//.....
}
function ajaxGetTopicRatings() {
var request = $j.ajax({
url: "json.php",
type: "GET",
data: {"items": items},
cache: true,
contentType: 'application/json; charset=utf-8',
});
request.done(function(data) {
//console.log(data);
obj = jQuery.parseJSON(data);
setTopicsSpans();
});
//......
}
function setTopicsArray() {
$j('[data-tid]').each(function() {
items.push(this.getAttribute('data-tid'));
});
ajaxGetTopicRatings();
}
setTopicsArray();
});
Now I read a bit about callback functions. but when I put in put in for example "setTopicsSpans" in function ajaxGetTopicRatings(setTopicSpans) I get an an error that the function: "setTopicsSpans" doesnt exist. Anyone have an idea how to do this?
Aucun commentaire:
Enregistrer un commentaire