<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: examining json_encoded response from within client side: emtpy grid</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>ivanb on examining json_encoded response from within client side: emtpy grid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23911</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23911</guid>
        	        	<description><![CDATA[<p>Sad when you have to reply to yourself...</p>
</p>
<p>Anway, it turns out that when I used wireshark to examine communication between my ADOBE AIR</p>
<p>application that runs jquery/jqgrid from within.... I saw an OLD debug message getting appended to my JSON string.</p>
<p>As soon as I removed that the grid loaded.</p>
<p>SO........... Please let others know that if firebug is NOT an option that wireshark examination of communication between</p>
<p>the client (jqgrid) and the upstream server will ALSO show you POST/REPONSE messages....</p></p>
]]></description>
        	        	<pubDate>Thu, 07 Jul 2011 21:04:24 +0300</pubDate>
        </item>
        <item>
        	<title>ivanb on examining json_encoded response from within client side: emtpy grid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23890</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23890</guid>
        	        	<description><![CDATA[<p>Using THIS server side code</p>
<p>ob_start();<br />print_r( $response );<br />$output = ob_get_clean();<br />file_put_contents( &#39;log.txt&#39;, file_get_contents( &#39;log.txt&#39; ) . $output );</p>
</p>
<p>I see my $response array from json_encode looks like this</p>
</p>
<p>stdClass Object<br />(<br />&#160;&#160;&#160; [page] =&#62; 1<br />&#160;&#160;&#160; [total] =&#62; 1<br />&#160;&#160;&#160; [records] =&#62; 2<br />&#160;&#160;&#160; [rows] =&#62; Array<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; (<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [0] =&#62; Array<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [id] =&#62; 0<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [cell] =&#62; Array<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [0] =&#62; 0<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [1] =&#62; peter <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [2] =&#62; parker<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [3] =&#62; 8976543420877<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [1] =&#62; Array<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [id] =&#62; 1<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [cell] =&#62; Array<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [0] =&#62; 1<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [1] =&#62; silver<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [2] =&#62; surfer<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [3] =&#62; 98765434245<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; )<br />)</p>
</p>
<p>Does this look correct?????????????</p></p>
]]></description>
        	        	<pubDate>Wed, 06 Jul 2011 05:06:53 +0300</pubDate>
        </item>
        <item>
        	<title>ivanb on examining json_encoded response from within client side: emtpy grid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23885</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23885</guid>
        	        	<description><![CDATA[<p>Re-adding my code... sorry it got HTML jumbled....</p>
</p>
<p>The HTML looks like<br />&#160;&#160;&#160; &#60;script src="lib/jquery/jquery-1.5.2.min.js" type="text/javascript" &#62;&#60;/script&#62;<br />&#160;&#160;&#160;&#160; &#60;script src="lib/jquery/jquery-ui.min.js" type="text/javascript"&#62; &#60;/script&#62;<br />&#160;&#160;&#160; &#60;script src="lib/jqgrid/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#160;&#160;&#160; &#60;script src="lib/jqgrid/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#160;&#160;&#160; &#60;div id="search"&#62;<br />&#160;&#160;&#160;&#160; &#60;table id="list"&#62;&#60;/table&#62;<br />&#160;&#160;&#160;&#160; &#60;div id="pager" &#62;&#60;/div&#62;<br />&#160;&#160;&#160;&#160;&#160;&#160; &#60;/div&#62;</p>
<p>The database and PHP are LOCAL for now and MYSQLi queries are getting the correct data everytime.</p>
<p>Javascript looks like</p>
<p>$(&#39;#list&#39;).jqGrid({<br />url:&#39;<a href="http://localhost/ajax-search.php&#039;," rel="nofollow" target="_blank"></a><a href="http://localhost/ajax-search.php&#038;#039" rel="nofollow" target="_blank"><a href="http://localhost/ajax-search.p" rel="nofollow">http://localhost/ajax-search.p</a>.....&#038;#039</a>;,<br />datatype: &#39;json&#39;,<br />postData: {<br />user: function() { return jQuery("input#username").val(); },<br />pass: function() { return jQuery("input#password").val(); },<br />firstname: function() { return jQuery("#firstname_label").val(); },<br />lastname: function() { return jQuery("#lastname_label").val(); },<br />number: function() { return jQuery("#number_label").val(); }<br />},<br />mtype: &#39;POST&#39;,<br />colNames:[&#39;id&#39;,&#39;First&#39;,&#39;Last&#39;, &#39;Number&#39;],<br />colModel:[<br />{name: &#39;id&#39;,&#160; index:&#39;id&#39;,width:10,hidden:false},<br />{name: &#39;targetfirstname&#39;,&#160; index:&#39;targetfirstname&#39;,width:25},<br />{name: &#39;targetlastname&#39;,&#160;&#160; index:&#39;targetlastname&#39;,width:25},<br />{name: &#39;number&#39;,&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;number&#39;, width:25},<br />],<br />rowNum:10,<br />width:340,<br />height: 25,<br />setGridHeight:45,<br />shrinkToFit:true,<br />rowList:[10,20,30],<br />imgpath: &#39;lib/jquery/themes/base/images&#39;,<br />pager: $(&#39;#pager&#39;),<br />sortname: &#39;id&#39;,<br />viewrecords: true,<br />sortorder: "desc",<br />caption:"Edit records",<br />});</p>
<p>The PHP/MYSQL (prepared statemenst in use) looks like</p>
<p>$response = new stdClass();<br />$response-&#62;page =&#160;&#160;&#160;&#160;&#160; $page;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // current page<br />$response-&#62;total =&#160;&#160;&#160;&#160; $total_pages;&#160;&#160;&#160; // total pages<br />$response-&#62;records =&#160;&#160; $numrows;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // total records<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $stmt2-&#62;execute()<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#124;&#124; fail(&#39;MySQL execute&#39;, $db-&#62;error);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $stmt2 -&#62; bind_result($seltargetfirstname,$seltargetlastname,$selnumber )<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#124;&#124; fail(&#39;MySQL bind_result&#39;, $db-&#62;error);</p>
<p>$i=0;<br />while($row = $stmt2-&#62;fetch()) {<br />&#160; fwrite($fh2,"\n I is $i \n");<br />&#160; $response-&#62;rows[$i][&#39;id&#39;]=$i;<br />&#160; $response-&#62;rows[$i][&#39;cell&#39;]=array($i,$seltargetfirstname,$seltargetlastname,$selnumber);<br />&#160; $i++;<br />&#160; fwrite($fh2, "\nTO ENCODER $i $seltargetfirstname $seltargetlastname $selnumber\n");<br />}</p>
<p>echo json_encode($response);</p>
<p>What I see is</p>
<p>[1] NO Apache/PHP/JSON encode or MYSQL&#160; errors<br />[2] I can write out the returned MYSQLI fetch values to a file, all look good<br />[3] I generate a row number as I dont use/need these in my schema<br />[4] The grid generates in JQGRID and I can sort and see my query re-execute but&#160; NO data</p>
]]></description>
        	        	<pubDate>Tue, 05 Jul 2011 23:41:16 +0300</pubDate>
        </item>
        <item>
        	<title>ivanb on examining json_encoded response from within client side: emtpy grid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23884</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/examining-json_encoded-response-from-within-client-side-emtpy-grid#p23884</guid>
        	        	<description><![CDATA[<p>Hi, I am using Jquery 1.5.1 and JQgrid 1.4.1 from within an Adobe AIR client, not a browser.</p>
<p>My server side is apache/PHP533 (with Json enabled) and MYSQL.</p>
<p><strong>I keep getting my grid rendered correctly but no data.</strong></p>
<p>Its tricky to invoke firebug to examine what the json_encode on the PHP server side did.</p>
</p>
<p>Is there anyway I can examine the JSON response from within my client side inside</p>
<p>my jquery code. I need to see whats INSIDE $response sent BACK to jqgrid</p>
<p>Pertinent code below</p>
</p>
<table border="0">
<tbody>
<tr>
<td class="votecell">
<div class="vote"><a class="star-off" title="This is a favorite question (click again to undo)" href="http://stackoverflow.com/questions/6566137/empty-grid-returned-to-jqgrid-4-1-1-with-jquery-1-5-2" target="_blank"></a></div>
</td>
<td class="postcell">
<div>
<div class="post-text">
<p>I am having real difficulty getting data to show in my grid. Queries can be used to retricve data by firstname, lastname or a &#39;serialnumber&#39;</p>
<p>The HTML looks like</p>
<pre class="default prettyprint"><p><input type='button' class='sfcodeselect' name='sfselectit1736' value='Select Code' data-codeid='sfcode1736' /></p><div class='sfcode' id='sfcode1736'>&#160; &#160; &#60;script src="lib/jquery/jquery-1.5.2.min.js" type="text/javascript" &#62;&#60;/script&#62;<br />&#160; &#160; &#160;&#60;script src="lib/jquery/jquery-ui.min.js" type="text/javascript"&#62; &#60;/script&#62;<br />&#160; &#160; &#60;script src="lib/jqgrid/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#160; &#160; &#60;script src="lib/jqgrid/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#160; &#160; &#60;div id="search"&#62;<br />&#160; &#160; &#160;&#60;table id="list"&#62;&#60;/table&#62;<br />&#160; &#160; &#160;&#60;div id="pager" &#62;&#60;/div&#62;<br />&#160; &#160; &#160; &#160;&#60;/div&#62;<br /></div></pre>
</p>
<p>The MYSQLi queries are getting the correct data everytime (I check on server side)</p>
<p>Javascript looks like</p>
<pre>$(&#39;#list&#39;).jqGrid({<br />url:&#39;<a href="http://localhost/ajax-search.php&#039;," rel="nofollow" target="_blank">http://localhost/ajax-search.php&#039;,</a><br />datatype: &#39;json&#39;,<br />postData: {<br />user: function() { return jQuery("input#username").val(); },<br />pass: function() { return jQuery("input#password").val(); },<br />firstname: function() { return jQuery("#firstname_label").val(); },<br />lastname: function() { return jQuery("#lastname_label").val(); },<br />number: function() { return jQuery("#number_label").val(); }<br />},<br />mtype: &#39;POST&#39;,<br />colNames:[&#39;id&#39;,&#39;First&#39;,&#39;Last&#39;, &#39;Number&#39;],<br />colModel:[<br />{name: &#39;id&#39;,  index:&#39;id&#39;,width:10,hidden:false},<br />{name: &#39;targetfirstname&#39;,  index:&#39;targetfirstname&#39;,width:25},<br />{name: &#39;targetlastname&#39;,   index:&#39;targetlastname&#39;,width:25},<br />{name: &#39;number&#39;,       index:&#39;number&#39;, width:25},<br />],<br />rowNum:10,<br />width:340,<br />height: 25,<br />setGridHeight:45,<br />shrinkToFit:true,<br />rowList:[10,20,30],<br />pager: $(&#39;#pager&#39;),<br />sortname: &#39;id&#39;,<br />viewrecords: true,<br />sortorder: "desc",<br />caption:"Edit records",<br />});<br /><br /></pre>
<p>The PHP/MYSQL (prepared statemenst in use) looks like</p>
<pre>$response = new stdClass();<br />$response-&#62;page =      $page;           // current page<br />$response-&#62;total =     $total_pages;    // total pages<br />$response-&#62;records =   $numrows;        // total records<br />                $stmt2-&#62;execute()<br />                &#124;&#124; fail(&#39;MySQL execute&#39;, $db-&#62;error);<br />                $stmt2 -&#62; bind_result($seltargetfirstname,$seltargetlastname,$selnumber )<br />                &#124;&#124; fail(&#39;MySQL bind_result&#39;, $db-&#62;error);<br /><br />$i=0;<br />while($row = $stmt2-&#62;fetch()) {<br />  fwrite($fh2,"\n I is $i \n");<br />  $response-&#62;rows[$i][&#39;id&#39;]=$i;<br />  $response-&#62;rows[$i][&#39;cell&#39;]=array($i,$seltargetfirstname,$seltargetlastname,$selnumber);<br />  $i++;<br />  fwrite($fh2, "\nTO ENCODER $i $seltargetfirstname $seltargetlastname $selnumber\n");<br />}<br /><br />echo json_encode($response);<br /><br /></pre>
<p>What I see is</p>
<pre>[1] NO Apache/PHP/JSON encode or MYSQL  errors<br />[2] I can write out the returned MYSQLI fetch values to a file, all look good<br />[3] I generate a row number as I dont use/need these in my schema<br />[4] The grid generates in JQGRID and I can sort and see my query re-execute but  NO data<br />    in the grid at all..<br /></pre>
</div>
</div>
</td>
</tr>
</tbody>
</table>
]]></description>
        	        	<pubDate>Tue, 05 Jul 2011 23:34:38 +0300</pubDate>
        </item>
</channel>
</rss>