jQuery 检测表单是否有要提交的值并显示 jQuery 消息插件。这是我的代码:
html:
<form name="sample" method="post" action="test.php?success" autofocus id="sample">
<input type="text" id="text" class="text">
<input type="submit" id="submit" class="submit">
</form>
javascript:
$(document).ready(function() {
$('#sample').submit(function(){
$.ajax({
type: "POST",
url: 'test.php?success',
data:$('#sample').serialize(),
success: function() {
$.msg({
fadeIn : 500,
fadeOut : 200,
timeOut : 800,
content : 'Successfully Saved',
css:{
border : '5px solid #C5C6C6',
background : '#EFFBFF',
},
})};
});
});
})