我在遵循其他人的代码时遇到了困难,如果有人可以帮助我解决这个问题,我将不胜感激。
基本上,我有一个显示预订列表的 Jqgrid,当您双击一行时,它会打开一个 jqdialog,其中显示有关其预订的所有详细信息。
我定义了一个变量,它是我想要传递给 php 脚本的预订参考。
var brData = rowData['bookref'];
然后我试图通过ajax发送这个:
function getGridRow(brData) {
$.ajax({
// Request sent from control panel, so send to cp.request.php (which is the handler)
url: 'scripts/php/bootstrp/all.request.php',
type: 'POST',
data: {
ft: "getDGRow",
type: 'POST',
data: 'fnme=getDGRow&row_data='+brData,
//row_data: rowData,
id: null,
condition: null
},
dataType: 'xml',
timeout: 20000,
error: function(){
$('#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){
}
});
all.request.php 中就是这种情况:
case 'getDGRow':
header('Content-type: text/xml');
DatagridController::getGridRow($_REQUEST['row_data']);
break;
这就是我要传递变量“brData”的地方:
public static function getGridRow($row_data) {
$pdo = new SQL();
$dbh = $pdo->connect(Database::$serverIP, Database::$serverPort, Database::$dbName, Database::$user, Database::$pass);
try {
$query = "SELECT * FROM tblbookings WHERE bookref = '$row_data'";
我现在发现这非常令人困惑,所以任何帮助将不胜感激。目前 $row_data 是我的 php 函数是空白的,所以显然它没有从数据库中选择任何行。