doupu7651 2015-09-23 14:15
浏览 33
已采纳

看看动作的php页面返回什么

For example, in an AJAX call, I would do that:

$.ajax({
        type: ...,
        url: bla.php,
        data: ..,
        success: function(msg) {
            alert(msg);
            ...

which would give me what bla.php would return, for example by an echo.

How to do that with my form too?


So, now my form looks like this:

<form action="url.php" method="post">
  Slot:<input type="text" name="slot" value="<?=$varSlot;?>">
  <input type="submit" name="formSubmit" value="Submit">
</form>

How can I see what url.php returns?

  • 写回答

1条回答 默认 最新

  • duanmei1946 2015-09-23 14:30
    关注

    first of all, understand that your form is gonna be redirected to "url.php", you are going to tell the browser to send that form to that page, so it will redirect to that page.

    Possibilities 1 - let it be like it is, and in the "url.php" put the code you wanna show, an processe wathever you want

    2 - Use ajax instead and retrieve wathever you want to be from "url.php"

    3 - If you just want to process the data and get back to the same page you are right now, user redirect("page.php") and it will redirect to that page once it's finished.

    4 - Use something like this to make use of ajax and return wathever is in the "url.php" files

    <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>
    

    NOTE: note that the submit function is pointing to a form id, and the "load" point wherever you want to put the codeor wathever is in the other "url.php" page.

    Hope it helps

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题