【发布时间】:2013-03-24 20:02:04
【问题描述】:
我使用 jquery 尝试了类似的操作,但失败了。
$.ajax({
type: "POST",
url: "myphphere.php",
data: {
command: $('#command').var()
}
});
我也想过使用按钮的onclick属性刷新页面来提交表单。
【问题讨论】:
我使用 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>
希望它能解决你的问题。
【讨论】:
Jquery Ajax 是你需要的。
将命令发送到 php 脚本很简单:
$.ajax({
type: "POST",
url: "some.php",
data: { command: $('#command').val()}
}).done(function( msg ) {
alert( "result : " + msg );
});
您可以接收命令结果并可以在任何您想要的地方显示(无需刷新页面)
【讨论】: