フォームをjavascriptで処理して送信しないようにするには、ユーザーが送信ボタンを押したときにフォーム上で発生するsubmit
イベントでリスナーを追加する必要があります。単にあなたのフォーム要素にid
属性を追加します。
<form method="get" id="myForm">
...
</form>
その後リスナーを追加:URLは何
<script>
$(function(){
$("#myForm').on('submit', function(event) {
event.preventDefault(); // This line prevents the normal behaviour of the submit button
var queryString = $(this).serialize(); // This will generate a query string like so : "val=1223&val2=434334&val3=4343"
var url = "http://server/cgi-bin/status.py?" + queryString; // Now you have the full URL
// Then you can send an AJAX request to a server-side script that will send the mail
$.ajax({
url: 'http://server/cgi-bin/email.py', // Your e-mailing script
method: 'POST', // or GET whatever
data: {
url: url,
email: '[email protected]'
},
...
})
})
})
</script>
を?これはあなたのフォームのフィールドですか? – mrid
こんにちは、ようこそ。私はあなたがこのグループからより良い結果を得るためにこのリンクを見直したいかもしれないと思います。 http://stackoverflow.com/help/how-to-ask –