jqueryを使用してこのようなことを試しましたが、失敗しました。
$.ajax({
type: "POST",
url: "myphphere.php",
data: {
command: $('#command').var()
}
});
また、ボタンのonclick属性を使用してページを更新し、フォームを送信することも考えました。
なぜtarget
フォームで属性を使用するのですか?
<form action="..." target="an_iframe" type="post">
<input type="text" name="cmd" placeholder="type a command here..." />
<input type="submit" value="Run!" />
</form>
<iframe id="an_iframe"></iframe>
それがあなたの問題を解決したことを願っています。
JqueryAjaxはあなたが必要とするものです。
コマンドをphpスクリプトに送信するのは簡単です:
$.ajax({
type: "POST",
url: "some.php",
data: { command: $('#command').val()}
}).done(function( msg ) {
alert( "result : " + msg );
});
コマンドの結果を受け取り、好きな場所に表示できます(ページを更新する必要はありません)