执行PHP不留页 [英] Execute PHP without leaving page

查看:88
本文介绍了执行PHP不留页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好。我有一个表格 - 文本区域(命名为苏),并提交按钮。

Okay. I have a form - textarea (named "su") and submit button.

当提交表单时,我需要

  1. 在无刷新/离开网页运行PHP脚本
  2. 在回声或以某种方式打印在屏幕上一回

我是pretty的肯定通过某种形式的Ajax请求的事情这工作。但我不知道我在说什么。 我不是大了Ajax或JavaScript,但是这是一个功能,我使用非常频繁,我想了解它是如何工作的,所以我可以实现它,当我需要现在和未来。

I'm pretty sure this works via some kind of ajax request thing. but I have no idea what I'm talking about. I'm not big on ajax or javascript, but this is a function i use very frequently and I'd like to learn how it works so I can implement it when i need to now and in the future.

就像我说的,我没有受过教育与AJAX和Java。一个简单的例子将是美好的。

Like i said I'm uneducated with ajax or java. a quick example would be wonderful.

感谢您抽出宝贵时间阅读!

thanks for taking the time to read!

推荐答案

简单,那就是所谓AJAX。解决的办法是更多的JavaScript,比PHP。  使用jQuery,你可以用一个简单的函数调用做到这一点。

Simple , that is what is called AJAX. The solution is more of Javascript, than PHP. Using Jquery, you can do it with a simple function call.

      <script src="jquery.js"></script>

    <script type="text/javascript">
     $(document).ready(function(){
            $('#ID_Of_Your_Button').change(function(){
                 $.ajax({
                       type: "GET",
                       url: "send.php",
                       data: "query="+document.form.textarea.value,
                       success: function(msg){
                        document.getElementById("Div_Where_you_want_the_response").innerHTML = msg                         }
                     })
            });
        });


    </script>

是卓有成效的。

Does the trick.

这篇关于执行PHP不留页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆