我的网站上有一个 fafor
网站,提交时用户从 Page1.html
到 Page2.html
。
我想在所提交的表格和“加载2号页面”的表格之间显示一个信息 加载>。
有人能给我举个例子吗?
我的网站上有一个 fafor
网站,提交时用户从 Page1.html
到 Page2.html
。
我想在所提交的表格和“加载2号页面”的表格之间显示一个信息 加载>。
有人能给我举个例子吗?
如果您的表格通过 ajax 提交数据, 您可以尝试一下:
$( form#myform ).submit(function(e) {
e.preventDefault();
$( #message ).html( Sending.... ); // #message may be a div that contains msg
$ajax({
url: url_to_script ,
data: your_data ,
success: function(res) {
// when submit data successfully then page reload
window.location = page2.html
}
});
});
您所要做的事情无法通过标准表格提交方式完成 。
您会想要使用 ajax 提交表格, 并在等待回复时显示“ 请稍候 ” 消息 。 一旦收到回复, 并验证回复是否有效, 然后您就可以将用户转到您现在拨打的第2页的页面上 。
通过 ajax 提交表格的最简单方式是 < a href=" https://stackoverflow.com/ questions/672045/how-to-sergize- a-form-in-to- a-of-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-to-tree-tree-st-结构”> 将表格序列化
然后,联署材料将需要解释下一步行动。
This is not tested, but copied and pasted from various working projects.
You ll need to download and include the json2.js
project.
<强>第1页 强>
<div id= pleaseWait >Please Wait...</div>
<form id="theForm" onsubmit="doAjaxSubmit();">
<input type= text name= age id= age />
<input type= submit value= submit >
</form>
<script type="text/javascript">
function doAjaxSubmit(){
var j = JSON.stringify($( #theForm ).serializeObject());
$( #pleaseWait ).slideDown( fast );
$.post( processor.php?j= + encodeURIComponent(j), function(obj){
if(obj.status== OK ){
window.location= page2.php ;
}else{
$( #pleaseWait ).slideUp( fast );
alert( Error: + obj.msg);
}
}, json );
return(false);
}
$.fn.serializeObject = function(){
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || );
} else {
o[this.name] = this.value || ;
}
});
return o;
};
</script>
<强度 > 处理器.php 强度 >
<?php
$j=json_decode($_POST[ j ], true);
if ((int)$j[ age ]<=0 || (int)$j[ age ]>120){
$result = array( status => ERR , msg => Please Enter Age );
}else{
//Do stuff with the data. Calculate, write to database, etc.
$result = array( status => OK );
}
die(json_encode($result));
?>
这基本上与下面的答案非常相似(通过
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...
<form><input type="file" name="first" onchange="jsFunction(2);"> <input type="file" name="second" onchange="jsFunction(3);"</form> Possible to pass just numbers to the js ...
So I ve got a menu with a hover/selected state and it loads fine in IE6/IE7. However when I scroll down the page and put the element outside of the viewport and then back in I get a broken image! I ...
I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!