簡単に見えるかもしれませんが、非常に難しいと思います。
iveは、PHPを使用する検索スクリプトを作成し、結果を取得するには次のようになります。
search.php?term=alice&submit=Submit
標準的な問題は、AJAXとPHPでSPIを使用しているため、ユーザーが検索前にアクセスしたページを失わないように、ハッシュ値を保持したまま、結果をdivに動的にロードする必要があることです。
jQuery.history.jsは、戻るボタンのサポートに使用するプラグインであり、次のようなリンクが必要です。
<a href="#home">Home Page</a>
これにより、「home.html」がpageContentという名前のdivにロードされます。私の知る限り、私が持っている小さなハックを開発しない限り、phpファイルを呼び出す方法はありません。
これが私の検索フォームのJavaScript/jQueryです。
<script language="JavaScript">
$(document).ready(function() {
// bind form using ajaxForm
$('#search1').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#pageContent',
// success identifies the function to invoke when the server response
success: function() {
$('#pageContent');
var hash = '#search.php?term='+($('#query').val()+'&submit=Submit').replace(/ /g, '+');
var stripped = hash.replace(/(<([^>]+)>)/ig,"");
update(window.location.hash = stripped);
}
});
});
</script>
フォームは次のとおりです。
<form id="search1" action="search.php" method="post">
<input id="query" type="text" name="term" />
<input type="submit" name="submit" value="Submit" />
</form>
私の問題はこれです:iveはこれを試しthis.form.reset();
ました:jQueryで多段階フォームをリセットしますが、これはどれも機能しません。あなたがこれをする方法を知っているならば、私を助けてください。