ユーザー名とパスワードを含む HTML フォームがあります。送信ボタンをクリックしたら、2 つの異なるサーバーで 2 つの異なる PHP メソッドに投稿したいと考えています。これはどのように行うことができますか?これは HTML フォームを使用して実行できますか? または、JavaScript を使用する必要がありますか? 助言がありますか?
アップデート
次のコードを試しましたが、うまくいきません。ここでどこが間違っていますか?前もって感謝します..!
<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
<title id="login_form">Login Form testing</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$('#loginform').submit(function(){
$("form" ).on( "submit", function( event ) {
event.preventDefault(); // prevent the default submission behavior
var data = $(this).serialize(); // gather data from the form and serialize it
$.post('URL_1', data, successAction1); // post it to destination 1
$.post('URL_2', data, successAction2); // post it to destination 2
});
var successAction1 = function() { alert("Success one");};
var successAction2 = function() { alert("Success two");};
});
</script>
</head>
<body>
<form id="loginform" action="">
<fieldset >
<legend>Login</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<label for='username' >UserName*:</label>
<input type='text' name='username' id='username' maxlength="50" />
<label for='password' >Password*:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type='submit' name='Submit' value='Submit' />
</fieldset>
</form>
</body>