【发布时间】:2015-09-22 13:12:55
【问题描述】:
我对 AJAX 不是很了解,但我很确定它可以解决我的问题。
我想在<TH> onclick 上更新一个 php 变量。然后,该变量将用于使用 Jquery 表排序脚本对我的某些列进行排序。
在页面顶部 (bodyshops.php) 我有这个...
if (isset($_GET['sortStore'])) {
$sortStore = $_GET['sortStore'];
}else{
$sortStore = 'EMPTY';
}
在桌端我有这个...(我以$sortStore = 'X'为例)
<th style="text-align:left; cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '1' ?>"><?php echo $LANGT_Bodyshop_Name; ?></th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '1' ?>"> <?php echo $LANGT_Bodyshop_Contact; ?></th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '2' ?>"> <?php echo $LANGT_Bodyshop_Email; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '3' ?>"> <?php echo $LANGT_Bodyshop_Phone; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '4' ?>"> <?php echo $LANGT_Bodyshop_AddressPostcode; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '5' ?>"> <?php echo $LANGT_Bodyshop_Capacity; ?> </th>
<th style="cursor:pointer; background-color:#0a639d; color:#ffffff;" onclick="<?php $sortStore = '6' ?>"> <?php echo $LANGT_Bodyshop_CourtesyCars; ?> </th>
最终目标是能够编写一个 if 语句来决定运行什么 jQuery 脚本。
即
if ( $sortStore != 0 ) {
// Run Function 1
}else{
// Run Function 2
}
这最终将帮助我阻止 TableSorter 在刷新页面时丢失它的排序值。有人可以帮忙吗?
【问题讨论】:
标签: javascript php jquery html ajax