Forum
Topic RSS
23:34
05/07/2011
OfflineHi, I am using Jquery 1.5.1 and JQgrid 1.4.1 from within an Adobe AIR client, not a browser.
My server side is apache/PHP533 (with Json enabled) and MYSQL.
I keep getting my grid rendered correctly but no data.
Its tricky to invoke firebug to examine what the json_encode on the PHP server side did.
Is there anyway I can examine the JSON response from within my client side inside
my jquery code. I need to see whats INSIDE $response sent BACK to jqgrid
Pertinent code below
|
I am having real difficulty getting data to show in my grid. Queries can be used to retricve data by firstname, lastname or a 'serialnumber' The HTML looks like
The MYSQLi queries are getting the correct data everytime (I check on server side) Javascript looks like $('#list').jqGrid({
The PHP/MYSQL (prepared statemenst in use) looks like $response = new stdClass(); What I see is [1] NO Apache/PHP/JSON encode or MYSQL errors |
23:41
05/07/2011
OfflineRe-adding my code... sorry it got HTML jumbled....
The HTML looks like
<script src="lib/jquery/jquery-1.5.2.min.js" type="text/javascript" ></script>
<script src="lib/jquery/jquery-ui.min.js" type="text/javascript"> </script>
<script src="lib/jqgrid/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="lib/jqgrid/jquery.jqGrid.min.js" type="text/javascript"></script>
<div id="search">
<table id="list"></table>
<div id="pager" ></div>
</div>
The database and PHP are LOCAL for now and MYSQLi queries are getting the correct data everytime.
Javascript looks like
$('#list').jqGrid({
url:'http://localhost/ajax-search.p.....',
datatype: 'json',
postData: {
user: function() { return jQuery("input#username").val(); },
pass: function() { return jQuery("input#password").val(); },
firstname: function() { return jQuery("#firstname_label").val(); },
lastname: function() { return jQuery("#lastname_label").val(); },
number: function() { return jQuery("#number_label").val(); }
},
mtype: 'POST',
colNames:['id','First','Last', 'Number'],
colModel:[
{name: 'id', index:'id',width:10,hidden:false},
{name: 'targetfirstname', index:'targetfirstname',width:25},
{name: 'targetlastname', index:'targetlastname',width:25},
{name: 'number', index:'number', width:25},
],
rowNum:10,
width:340,
height: 25,
setGridHeight:45,
shrinkToFit:true,
rowList:[10,20,30],
imgpath: 'lib/jquery/themes/base/images',
pager: $('#pager'),
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Edit records",
});
The PHP/MYSQL (prepared statemenst in use) looks like
$response = new stdClass();
$response->page = $page; // current page
$response->total = $total_pages; // total pages
$response->records = $numrows; // total records
$stmt2->execute()
|| fail('MySQL execute', $db->error);
$stmt2 -> bind_result($seltargetfirstname,$seltargetlastname,$selnumber )
|| fail('MySQL bind_result', $db->error);
$i=0;
while($row = $stmt2->fetch()) {
fwrite($fh2,"\n I is $i \n");
$response->rows[$i]['id']=$i;
$response->rows[$i]['cell']=array($i,$seltargetfirstname,$seltargetlastname,$selnumber);
$i++;
fwrite($fh2, "\nTO ENCODER $i $seltargetfirstname $seltargetlastname $selnumber\n");
}
echo json_encode($response);
What I see is
[1] NO Apache/PHP/JSON encode or MYSQL errors
[2] I can write out the returned MYSQLI fetch values to a file, all look good
[3] I generate a row number as I dont use/need these in my schema
[4] The grid generates in JQGRID and I can sort and see my query re-execute but NO data
05:06
05/07/2011
OfflineUsing THIS server side code
ob_start();
print_r( $response );
$output = ob_get_clean();
file_put_contents( 'log.txt', file_get_contents( 'log.txt' ) . $output );
I see my $response array from json_encode looks like this
stdClass Object
(
[page] => 1
[total] => 1
[records] => 2
[rows] => Array
(
[0] => Array
(
[id] => 0
[cell] => Array
(
[0] => 0
[1] => peter
[2] => parker
[3] => 8976543420877
)
)
[1] => Array
(
[id] => 1
[cell] => Array
(
[0] => 1
[1] => silver
[2] => surfer
[3] => 98765434245
)
)
)
)
Does this look correct?????????????
21:04
05/07/2011
OfflineSad when you have to reply to yourself...
Anway, it turns out that when I used wireshark to examine communication between my ADOBE AIR
application that runs jquery/jqgrid from within.... I saw an OLD debug message getting appended to my JSON string.
As soon as I removed that the grid loaded.
SO........... Please let others know that if firebug is NOT an option that wireshark examination of communication between
the client (jqgrid) and the upstream server will ALSO show you POST/REPONSE messages....
Most Users Ever Online: 994
Currently Online:
17 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66
Log In
Home