i have jQuery code below..
(function( $ ) {
$.fn.pokerClass = function( test ) {
var test;
this.a = function(){
$.ajax({
type: "POST",
url: "http://127.0.0.1/test.php",
success: function(data){
var json = $.parseJSON(data);
test = json.value;
}
});
}
this.b = function() {
alert("i am " + test);
};
this.class_var = test;
return this;
};
})( jQuery );
HTML:
var t = $(document.body).testClass();
t.a();
t.b();
I get response "i am undefined". Can anyone help me how to solve this problem?