Home > Backend Development > PHP Tutorial > 页面提交刷新有关问题

页面提交刷新有关问题

WBOY
Release: 2016-06-13 12:22:03
Original
1105 people have browsed it

页面提交刷新问题
制作了一个简单页面:上面一排查询条件,点击查询,下半部分显示查询结果; 

现在问题是,点击查询后,怎么才能让上半部分不刷新,就是之前录入的查询信息不被清掉,求大家告知。
------解决思路----------------------
典型的Ajax应用
------解决思路----------------------
ajax就可以了。
给你写个简单例子:
client.html

<br /><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br /><html><br /> <head><br />  <meta http-equiv="content-type" content="text/html;charset=utf-8"><br />  <title> 测试 </title><br />  <script src="//code.jquery.com/jquery-1.11.3.min.js"></script><br /> </head><br /><br /> <body><br />    <div>key:<input type="text" id="key"><input type="button" id="btn" value="search"></div><br />    <div id="show"></div><br />    <script type="text/javascript"><br />    $('#btn').click(function(){<br />        $.post("server.php",{key:$('#key').val()})<br />        .done(function(data){<br />          $('#show').html(data['key']);<br />        });<br />    })<br /><br />    </script><br /> </body><br /></html><br />
Copy after login


server.php
<br /><?php<br />$key = isset($_POST['key'])? $_POST['key'] : '';<br />header('content-type:application/json;charset=utf-8');<br />echo json_encode(array('key'=>'你输入的key是:'.$key));<br />?><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template