This is my custom jQuery function:
(function($){
$.fn.NotYet = function(arti_id) {
this.append(function() {
var result = 0;
$.post("comment_load.php", {arti_id:arti_id, status:1}, function(data){
console.log(data); // Returns data from POSTed PHP file
console.log(result); // Returns 0
//$(this).append(result); // Not Working
result = data;
console.log(result); // Returns data from POSTed PHP file
});
console.log(result); // Returns 0
return result; // Returns 0
});
return this; // Returns 0
};
})(jQuery);
I am calling the function like this:
$("div#Comments").NotYet(15);
I am trying to make a jQuery function, but I am unable to return the posted php file data back to into the <div>
container.
Any suggestions?
FYI: This question is similar, but I could not understand what is happening and I needed a simple method. How do I return the response from an asynchronous call?