Skip to content

Instantly share code, notes, and snippets.

@kauanmocelin
Last active April 6, 2021 12:15
Show Gist options
  • Save kauanmocelin/c706c1db3e22af5f61e45e14489847a9 to your computer and use it in GitHub Desktop.
Save kauanmocelin/c706c1db3e22af5f61e45e14489847a9 to your computer and use it in GitHub Desktop.
[Ajax load vs html com JQuery] #jquery #ajax
If you want to load the response you are getting from your ajax server page to the div with Id dvShiftDialog, you can use the html method to do so.
html method will replace the current inner html of that element with the new content (in this case the content of msg variable)
var url="some-valid-url-to-handle-ajax";
$.ajax({
type : "POST",
url : url,
cache : false,
success : function(msg) {
$('#dvShiftDialog').html(msg);
}
});
EDIT : If you want to load the content of the whole page, why not have the container div load it with the load function , instead of making a POST call ? (i do not see you passing any parameter to the POST, so you can simply use the load method)
Assuming your HTML is like this
Now you can have this script to load some other content to it
<script type="text/javascript">
$(function(){
var url="some-awesome-page-content-url.php";
$("divContainer").load(url);
});
</script>
Make sure you have jQuery loaded to the page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment