查看php页面的操作returns
See what php page of action returns
例如,在 AJAX 调用中,我会这样做:
$.ajax({
type: ...,
url: bla.php,
data: ..,
success: function(msg) {
alert(msg);
...
这会给我 bla.php 会 return 的东西,例如 echo
.
如何使用我的表单来做到这一点?
所以,现在我的表单如下所示:
<form action="url.php" method="post">
Slot:<input type="text" name="slot" value="<?=$varSlot;?>">
<input type="submit" name="formSubmit" value="Submit">
</form>
我怎样才能看到 url.php return 的内容?
首先,了解您的表单将被重定向到 "url.php",您将告诉浏览器将该表单发送到该页面,因此它会重定向到该页面。
可能性
1 - 让它保持原样,然后在 "url.php" 中放入您想要显示的代码,随心所欲地进行处理
2 - 使用 ajax 并从 "url.php"
中检索你想要的任何内容
3 - 如果您只想处理数据并返回到您现在所在的同一页面,用户重定向("page.php"),它会在完成后重定向到该页面。
4 - 使用类似这样的东西来利用 ajax 和 return wathever 在 "url.php" 文件中
<form action="url.php" method="post" id="formName">
SLOT:<input type="text" name="slot" value="<?=$varSlot;?>">
<input type="submit" name="formSubmit" value="Submit">
</form>
<script>
$(function(){
$("#formName").submit(function(e){
$("#id-of-div-or-something").load("url.php");
e.preventDefault();
});
});
</script>
注意:请注意,提交函数指向一个表单 ID,"load" 指向您想要放置代码的任何位置或其他 "url.php" 页面。
希望对您有所帮助
例如,在 AJAX 调用中,我会这样做:
$.ajax({
type: ...,
url: bla.php,
data: ..,
success: function(msg) {
alert(msg);
...
这会给我 bla.php 会 return 的东西,例如 echo
.
如何使用我的表单来做到这一点?
所以,现在我的表单如下所示:
<form action="url.php" method="post">
Slot:<input type="text" name="slot" value="<?=$varSlot;?>">
<input type="submit" name="formSubmit" value="Submit">
</form>
我怎样才能看到 url.php return 的内容?
首先,了解您的表单将被重定向到 "url.php",您将告诉浏览器将该表单发送到该页面,因此它会重定向到该页面。
可能性 1 - 让它保持原样,然后在 "url.php" 中放入您想要显示的代码,随心所欲地进行处理
2 - 使用 ajax 并从 "url.php"
中检索你想要的任何内容3 - 如果您只想处理数据并返回到您现在所在的同一页面,用户重定向("page.php"),它会在完成后重定向到该页面。
4 - 使用类似这样的东西来利用 ajax 和 return wathever 在 "url.php" 文件中
<form action="url.php" method="post" id="formName">
SLOT:<input type="text" name="slot" value="<?=$varSlot;?>">
<input type="submit" name="formSubmit" value="Submit">
</form>
<script>
$(function(){
$("#formName").submit(function(e){
$("#id-of-div-or-something").load("url.php");
e.preventDefault();
});
});
</script>
注意:请注意,提交函数指向一个表单 ID,"load" 指向您想要放置代码的任何位置或其他 "url.php" 页面。
希望对您有所帮助