我有一个预订网格,如下所示:
在这个预订网格上,我有一个 dblClick 事件,它打开了一个 Jquery 对话框:
<div id="cp-bookings-dialog">
<div class="cp-tiles-wrapper-dlg">
<div class="cp-booking-info left">
<p class="pno-margin">Booking Date: <strong>Booking Reference is = <? echo BookingDocket::get_bookref(); ?></strong></p>
<p class="pno-margin">Return Date: <strong><? echo BookingDocket::get_bookdate(); ?></strong></p>
<p class="pno-margin">Journey: <strong></strong></p>
<p class="pno-margin">Passenger Tel: <strong></strong></p>
<p class="pno-margin">E-mail: <strong></strong></p>
</div>
</div>
</div>
jQuery代码:
ondblClickRow: function(rowid)
{
var rowData = new Array();
rowData = $("#bookings").getRowData(rowid);
var brData = rowData['bookref'];
getGridRow(brData);
$("#cp-bookings-dialog").dialog({ hide: 'slide', height: 625, width: 733, title: 'Booking Reference: - '+ brData});
},
其中 brData 是我想在我的 PHP 脚本中使用的“预订参考”值。目前这个 dblClick 事件被发送到以下 Ajax 请求:
function getGridRow(brData) {
$.ajax({
url: 'scripts/php/bootstrp/all.request.php',
type: 'POST',
data: {
rowdata: brData,
id: null,
condition: null
},
dataType: 'text/xml',
timeout: 20000,
error: function(){
alert("It failed");
$('#cp-div-error').html('');
$('#cp-div-error').append('<p>There was an error inserting the data, please try again later.</p>');
$('#cp-div-error').dialog('open');
},
success: function(response){
// Refresh page
//response = brData;
//alert(response); <--- This alerts the correct Booking Reference
}
});
哪个被发送到 all.request.php
// Switch to determine method to call
switch ($_REQUEST['fnme']) {
case 'getDGRow':
header('Content-type: text/xml');
GetBookings::getGridRow($_REQUEST['rowdata']);
break;
最后到我想使用这个 Jquery 值的 PHP 脚本:
class GetBookings {
public static function getGridRow($rowdata) {
$rowdata = $_REQUEST['rowdata'];
$pdo = new SQL();
$dbh = $pdo->connect(Database::$serverIP, Database::$serverPort, Database::$dbName, Database::$user, Database::$pass);
try {
$query = "SELECT * FROM tblbookings WHERE bookref = '$rowdata'";
$stmt = $dbh->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_BOTH);
{variables are all here}
$stmt->closeCursor();
}
catch (PDOException $pe) {
die("Error: " .$pe->getMessage(). " Query: ".$stmt->queryString);
}
$dbh = null;
}
}
我不知道为什么,但这似乎不起作用。另外,请注意,当您 dblClick 预订时,这会打开一个 jQuery 对话框,其中显示有关预订的所有详细信息,并且应该返回所有结果$query = "SELECT * FROM tblbookings WHERE bookref = '$rowdata'";
我需要做的就是正确地传递这些数据,这就像我$rowdata
用预订参考值替换一样,它应该可以正常工作。
如果有人可以帮助我解决这个问题,我将非常感激,因为我已经尝试了很长一段时间了:(