时间:2021-07-01 10:21:17 帮助过:16人阅读
在a.html中有ul,现在ul中有三个li,我现在是每点击一个li通过ajax获取到对应的数据,
然后在b.html中有三个a标签,问如何能实现在b.html中单击a标签跳到a.html中对应li中并得到相应的数据???
在a.html中有ul,现在ul中有三个li,我现在是每点击一个li通过ajax获取到对应的数据,
然后在b.html中有三个a标签,问如何能实现在b.html中单击a标签跳到a.html中对应li中并得到相应的数据???
以下是伪代码,仅供参考
b.html
- <code>跳转到LI_A并取得数据</code>
a.html
- <code><li class="myli">li_a</li>
- <li class="myli">li_b</li>
- <li class="myli">li_c</li>
- $('.myli').click(function () {
- loadData($(this).index());
- });
- // 进入页面判断参数,然后点击对应LI标签
- window.onload = function () {
- var index = getQuery('li')
- $('.myli').get(index).click();
- }</code>
- <code>这个demo你看下:
- 前台:
- <meta charset="utf-8">
- <input type="text" name="state" autocomplete="off">
- <br>
- 后台:
- <!--?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- $con = mysqli_connect("localhost", "root", "")
- or die("Failed to connect to the server: " . mysql_error());
- mysqli_select_db($con, "dedecms")
- or die("Failed to connect to the database: " . mysql_error());
- $partialStates = strtoupper($_GET['partialState']);
- if(!$partialStates)
- {
- echo "###";
- }
- else
- {
- $states = mysqli_query($con,"select typename from dede_arctype where typename like '%$partialStates%'") or die(mysql_error());
- $sources = array();
- while($row = mysqli_fetch_array($states)) {
- $sources[] = $row['typename'];
- }
- header('Content-Type: application/json');
- echo json_encode($sources);
- }
- </code--></code>
人气教程排行
-
174次
1
php如何获取跳转前的url
-
174次
2
php格林威治时间转换成当前时间的方法
-
174次
3
为什么php不能做大型系统?
-
174次
4
range函数怎么用
-
174次
5
php中计算页面加载时间几种方法总结_PHP教程
-
174次
6
求帮助,关于paypal支付返回值修改订单状态
-
174次
7
typecho怎么配置文章内容页?
-
174次
8
PhpStorm左侧structure不显示文件的方法列表是这么回事?
-
174次
9
查看PHP的环境变量_PHP
-
174次
10
PHP Primary script unknown 解决方法总结
-
174次
11
php的命名空间与自动加载实现方法
-
174次
12
解决laravel 出现ajax请求419(unknown status)的问题
-
173次
13
php 如何删除mysql记录
-
173次
14
PHP如何替换数组中的指定元素
-
173次
15
怎么去除字符串中非汉字、非字母、非数字的字符
-
173次
16
mysql如何一次执行多条SQL语句
-
173次
17
修改header里面的Connection为close解决方法
-
173次
18
PHP基于session.upload_progress 实现文件上传进度显示功能详解
-
173次
19
php5.6.x到php7.0.x特性小结
-
172次
20
php为什么会出现504错误