好。我有一个表格 - 文本区域(命名为苏),并提交按钮。
Okay. I have a form - textarea (named "su") and submit button.
当提交表单时,我需要
在无刷新/离开网页运行PHP脚本 在回声或以某种方式打印在屏幕上一回我是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.