I’m having diffiiculty with this as I’m following on from somebody elses code, if somebody could help me with this I would appreciate it.
Basically I have a Jqgrid that displays a list of bookings, when you double click a row it opens a jqdialog that displays all the details about their booking.
I have a variable defined which is the booking reference which I want to pass to a php script.
var brData = rowData['bookref'];
I am then trying to send this via 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){
}
});
this is the case in all.request.php:
case 'getDGRow':
header('Content-type: text/xml');
DatagridController::getGridRow($_REQUEST['row_data']);
break;
and this is where I want to pass the variable ‘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'";
I’m finding this very confusing at the moment, so any help would be much appreciated. At the moment $row_data is my php function is blank so obviously it isn’t selecting any row from the database.
Start with verifying that the javascript function is not passing a blank variable. Try alerting the variable “brData”. Second, verify if the ajax call is successful, probably by the use of firebug’s console. Third, make sure that the PHP receives it and can enter the function. You may try
in your PHP file and alert the value in your html.
If you can receive an alert from your scripts, I guess the last thing that you can try is
query manually to your database using the value of the variable that was sent back to you by your PHP script. Who knows, there really is no result for the produced query.