フォーム送信時に wordpress で sidebar.php を更新しようとしています (つまり、sidebar.php のウィジェットにあります)。
ページにビデオがあり、ページ全体が更新されると、ビデオを最初から再生する必要があります。
誰かがフォームを送信したときに sidebar.php を更新するだけの解決策が必要です... 私は PHP の専門家ではないので、シンプルが一番です!
ところで。フォームに手ごわいプラグインを使用しています。
前もって感謝します!
ajaxの仕事のようですね!
今、あなたはそれをゼロから行うことができますが、それは不必要に苦痛になります. 代わりに、これをヘッダーに追加して、ページにjqueryを含めることをお勧めします
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
(Google でホストされている最新バージョンを使用)
jquery をロードしたので、物事の流れを中断することなくデータを送信する簡単な方法がたくさんあります。これを行う方法は次のとおりです(method = "post"を使用していると仮定しています):
<input type="submit" >
して<button>
、クリックしても組み込みのフォーム送信がトリガーされないようにします (これにより、ビデオが中断されます)。<button id="mysubmitbutton">
ます。<input type="text" name="firstName" id="firstName">
(あなたがそれに取り組んでいる間に、気になるすべてのフォームフィールドに id 属性を与えてください<input type="text" name="firstName">
。<head>
一部に、次のようなコードを追加します。<script type="text/javascript">
//makes it so that it goes after the html document is ready for it
$(document).ready(function() {
//this ties a onclick event to your button you made
$("#mysubmitbutton").click(function(){
//when the button is clicked, it will asychronously post to where you want it to
$.post("urlthatwasinyouractionequalsattribute.php",
{
//put all your post variables here, referencing the ids you made earlier
firstName: $("#firstName").val(),
time: $("#time").val() //be sure you don't have a trailing comma on the last one
},
function(data) {
//data is whatever the other website sends back. do whatever you want here...
alert("Result: " + data);
});
});
});
</script>
それを起動すると、動作するはずです。明らかに、フォームなどに一致するように値を変更する必要があります。
それが役立つことを願っています! 回答した場合は、回答としてマークしてください。