Skip to content

Instantly share code, notes, and snippets.

@EihabShadeed
Last active December 10, 2015 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EihabShadeed/4394194 to your computer and use it in GitHub Desktop.
Save EihabShadeed/4394194 to your computer and use it in GitHub Desktop.
JavaScript: Self-Invoker
;( function(FunctionName, $, undefined) {
var $body = $('body'), $html = $('html'), $doc = $(document);
var ajax_fill = function(ajax_url, id_name)
{
$.ajax({
type: "GET",
dataType: "html",
url: ajax_url,
success: function(t) {
if ( t && t.length > 10 ) {
var e = $(id_name);
e.html(t);
e.css({"display": "block"});
}
}
});
};
var image_auto_req = function( q ) {
var ajax_url = "/a/imageauto?q=" + encodeURIComponent( q );
ajax_fill(ajax_url, "#image_auto_div");
};
$doc.ready(function() {
// Do Something
});
}(window.FunctionName = window.FunctionName || {}, jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment