jQuery code:
$(document).ready(function() {
$("#post_submit").click(function(event) {
event.preventDefault();
$("#show").load("post.php", {
submit: $("#post_submit").val(),
title: $("#title").val(),
body: $("#body").val(),
tag开发者_如何学JAVAs: $("#tags").val()
});
});
});
This works fine, and the information is displayed in without the page reloading (yay), but it's not very smooth. I was wondering how I could make it appear slowly, like $(div).show("slow");
or $(div).toggle("slow")
.
The way to do this would be to load the new content into a hidden container. Then, chain a show('slow') to the end of the load event.
As shown in the jQuery documentation, load returns the jQuery object, so it can be chained with other events.
Something along the lines of
$("#show").hide();
$("#show").load("post.php", {
submit: $("#post_submit").val(),
title: $("#title").val(),
body: $("#body").val(),
tags: $("#tags").val()
}).show("slow");
精彩评论