目前我有一个 HTML 页面, 有许多文本框, 需要通过 Javascript 验证。 一旦它们全部被验证, 我想通过控制器创建用户账户 。 php
我的问题是: 我怎样才能从 Javascript 函数中将 PHP 文件放在 PHP 文件上 。 我认为我可以使用 AJax, 但是如果可能的话, 我想不用它。
感谢 谢谢
目前我有一个 HTML 页面, 有许多文本框, 需要通过 Javascript 验证。 一旦它们全部被验证, 我想通过控制器创建用户账户 。 php
我的问题是: 我怎样才能从 Javascript 函数中将 PHP 文件放在 PHP 文件上 。 我认为我可以使用 AJax, 但是如果可能的话, 我想不用它。
感谢 谢谢
创建带有日志方法的窗体, 并将其指向php 脚本。 如果您在下面设置了这样的窗体, 您不需要从 javascript 函数中发布, 因为 html 窗体的默认行为将会为您做发布 。 对于没有启用 javascript 的人来说, 它也会优雅地降低 。
<form action="/path.to.your.php.file.php" method="POST" onSubmit="return validate();">
... your fields...
<input type="submit" value="validate and submit"/>
</form>
<script>
function validate(){
// do your validation here
return true; // return true if validation was ok, false otherwise
}
</script>
如果您想要使用 AJAAX,请使用 JQuery 库,您可以做以下工作将
$.ajax({
type: POST ,
url: url,
data: data,
success: success,
dataType: dataType
});
或
$.post( controller.php , function(data) {
//do something with the result
});
指定您表格的名称, 像这样...
<form name="myForm" id="form1" method="post" action="phpScriptToPostTo.php">
...然后运行这个喷射器:
document.forms["myForm"].submit();
...或者这个在jQuery:
$( #form1 ).submit();
...或这个在jQuery的ajax:
$.post( server.php , $( #form1 ).serialize())
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!