Created
February 17, 2021 09:18
-
-
Save aabir/7b84496a0199bbdfbaf4b065db755bbb to your computer and use it in GitHub Desktop.
JQuery Ajax call as function and invoke the function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.extend({ | |
userCount: function() { | |
var result = null; | |
$.ajax({ | |
url:"yourURL.asp?param1="+val1+"¶m2="+val1=2, | |
type: 'get', | |
async: false, | |
success: function(data) { | |
result = data; | |
} | |
}); | |
return result; | |
} | |
}); | |
//Later call the function | |
if($.isFunction($.userCount) && $.userCount() == 1) //checking wether the function exist and comparing function return. | |
{ | |
//your code here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment