I'm building a website where I load new data into the page by making and ajax request to a PHP page which pulls new data and then appends it to the document. There is a vote counter that counts the number of votes. The only problem here is I'm using another load function to increase the number of votes.
Programmatically, it is as follows
$.ajax({
url: 'load.php',
type: 'POST',
data: data,
cache: false,
success: function (data) {
var json = jQuery.parseJSON(data);
if (json.status == 'newcontent') {
$('.loadafter').before(json.content)
}
});
$.ajax({
url: 'voteup.php',
type: 'POST',
data: data,
cache: false,
success: function (data) {
var json = jQuery.parseJSON(data);
if (json.status == 'success') {
$("#votecount"+).load("home.php #votecount" + postid);
}
the problem the second ajax request does not work for the new content that has been added by the previous Ajax request
Edit:The variable postid is used to target the post which is being voted up