【发布时间】:2016-05-16 18:10:42
【问题描述】:
我有一个我正在实施的票务系统,它的一个方面是根据是否已解决的票证生成表格,并且有一个下拉框,当它更改时将 AJAX 请求发送到另一个页面生成表格,这部分一切正常。我没有坚持的部分是从选定的票证中获取相关信息到引导模式中。我的意思是我有一个视图按钮,它位于生成表中每一行的最后一列,当他们单击此视图时,我想激活一个模式,该模式将具有票证以及 cmets 和一种方法解决它。我在想,也许我可以使用模式的 isShown 函数向某个页面发送 AJAX 请求,该页面可以使用票证 ID 生成该信息,我可以发送一些方法。这似乎是一个可能的解决方案?如果我要实施这个解决方案,发送ticketID的最简单方法是什么,我会为表格的每一行制作一个表格并制作一个隐藏字段,即id还是有更简单的方法?我创建表的代码如下:
if($_POST['ticketType'] == "UnresolvedTickets"){
$selectQuery = "SELECT * FROM tickets WHERE ticketsResolved = 'New' OR ticketsResolved = 'Open'";
$stmt = $dbh->prepare($selectQuery);
$stmt->execute();
$info = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<br>";
echo "<table style='width:100%; ' class = 'table table-striped table-bordered table-hover'>";
echo "<tr>";
echo" <th>Requestor</th>";
echo "<th>Description</th>";
echo "<th>Type</th>";
echo "<th>Status</th>";
echo "<th>Severity</th>";
echo "<th>Request Date</th>";
echo "<th>Ticket #</th>";
echo "<th>View Ticket</th>";
echo "</tr>";
foreach($info as $item){
echo "<tr>";
$date = $item['ticketDate'];
$newDate = date('Y-m-d h:i:s a', strtotime($date));
echo "<td>{$item['ticketContact']}</td><td>{$item['ticketDescription']}</td><td>{$item['ticketType']}</td><td>{$item['ticketsResolved']}</td><td>{$item['ticketStatus']}</td><td>{$newDate}</td><td>{$item['ticketID']}</td><td><a href='http://link'>view</a></td>";
echo "</tr>";
}
echo "</table>";
}else{
$selectQuery = "SELECT * FROM tickets WHERE ticketsResolved = 'Resolved'";
$stmt = $dbh->prepare($selectQuery);
$stmt->execute();
$info = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<br>";
echo "<table style='width:100%; ' class = 'table table-striped table-bordered table-hover'>";
echo "<tr>";
echo" <th>Requestor</th>";
echo "<th>Description</th>";
echo "<th>Type</th>";
echo "<th>Status</th>";
echo "<th>Severity</th>";
echo "<th>Request Date</th>";
echo "<th>Ticket #</th>";
echo "<th>View Ticket</th>";
echo "</tr>";
foreach($info as $item){
echo "<tr>";
$date = $item['ticketDate'];
$newDate = date('Y-m-d h:i:s a', strtotime($date));
echo "<td>{$item['ticketContact']}</td><td>{$item['ticketDescription']}</td><td>{$item['ticketType']}</td><td>{$item['ticketsResolved']}</td><td>{$item['ticketStatus']}</td><td>{$newDate}</td><td>{$item['ticketID']}</td><td><a href='http://link'>view</a></td>";
echo "</tr>";
}
echo "</table>";
}
是否有不同/更容易/更好的方式来实现这个模态想法,或者我的想法是否正确?如果我的想法是在正确的轨道上,我有点难过将 ticketID 放入 AJAX 调用以填充模式。
谢谢!
【问题讨论】:
标签: javascript php jquery ajax twitter-bootstrap