Skip to content

Instantly share code, notes, and snippets.

@aabir
Created February 17, 2021 09:18
Show Gist options
  • Save aabir/7b84496a0199bbdfbaf4b065db755bbb to your computer and use it in GitHub Desktop.
Save aabir/7b84496a0199bbdfbaf4b065db755bbb to your computer and use it in GitHub Desktop.
JQuery Ajax call as function and invoke the function
jQuery.extend({
userCount: function() {
var result = null;
$.ajax({
url:"yourURL.asp?param1="+val1+"&param2="+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