Created
October 6, 2014 15:36
-
-
Save eas604/b86a70fd36b267506aa1 to your computer and use it in GitHub Desktop.
Simple async view loader in jQuery. Gets the target URL, then puts the output HTML in the target div.
This file contains 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
function loadView(url, div) { | |
// Will get the result of the appropriate view url then display the data | |
// in the specified `div`, where `div` is a jQuery selector. Usage: | |
// var div = $("#my_target_div"); | |
// var url = "~/Example/View"; | |
// loadView(url, div); | |
$.get(url, function (data) { div.html(data); }, "html"); | |
// Parameter dataType value "html" required on Firefox only, for some reason. | |
// See http://stackoverflow.com/questions/11441020/jquery-ajax-exception-only-in-firefox-node-cannot-be-inserted-at-the-specified | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment