Skip to content

Instantly share code, notes, and snippets.

@seblavoie
Created December 14, 2012 22:07
Show Gist options
  • Save seblavoie/4289103 to your computer and use it in GitHub Desktop.
Save seblavoie/4289103 to your computer and use it in GitHub Desktop.
// Use to call views with self contained javascript function using backend
(function(){
$("[data-ajax-url]:not(.disabled)").on("click", function(e){
callAjaxScript(
$(this).attr("data-ajax-url"),
$(this).attr("data-ajax-type") || "get",
$(this).attr("data-ajax-data") || "");
});
})();
function callAjaxScript(url, type, data) {
$.ajax({
url: url,
type: type,
data: data || "",
dataType: "script"
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment