Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
jqGrid not reading data?
23/12/2008
23:15
Avatar
gpit2286
New Member
Members
Forum Posts: 2
Member Since:
23/12/2008
sp_UserOfflineSmall Offline

I have jqGrid implemented in my webpage and I am having an issue getting jqGrid to read the XML response from the server.  Using firebug, I am sure that that correct message is getting sent and the response seems right... but the data isn't displayed.  See Below :

Code :
echo "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>";
echo "<rows>";
echo "<page>".$pageNo."</page>";
echo "<total>".$lastPage."</total>";
echo "<records>".$CurCount."</records>";

while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<row id='". $row['id']."'>";           
            echo "<cell>". $row['artist']."</cell>";
            echo "<cell>". $row['album']."</cell>";
            echo "<cell>". $row['quanity']."</cell>";
            echo "<cell>". $row['price']."</cell>";
            echo "<cell>". $row['place']."</cell>";
            echo "<cell>". $row['link']."</cell>";
echo "</row>";
}
echo "</rows>";
?>

Response:

<?xml version="1.0" encoding="utf-8"?>
<rows><page>1</page><total>2</total><records>Array</records><row id='33'><cell>Driving Blind</cell><cell
>Driving Blind</cell><cell>2</cell><cell>0.77</cell><cell>Second Spin</cell><cell>http://www.secondspin
.com/cart.jsp?add=true&trans=buy&condition=used&type=1&price=0.77&id=885350</cell></row><row id='4'>
<cell>Bent Scepters</cell><cell>Blind Date with Destiny</cell><cell>7</cell><cell>1.47</cell><cell>Second
 Spin</cell><cell>http://www.secondspin.com/cart.jsp?add=true&trans=buy&condition=used&type=1&price=1
.47&id=847459</cell></row><row id='28'><cell>Budapest</cell><cell>Too Blind to Hear</cell><cell>7</cell
><cell>1.59</cell><cell>Second Spin</cell><cell>http://www.secondspin.com/cart.jsp?add=true&trans=buy
&condition=used&type=1&price=1.59&id=2219316</cell></row><row id='2'><cell>Ben Harper/Blind Boys of Alabama
</cell><cell>Live at the Apollo</cell><cell>2</cell><cell>10.99</cell><cell>Second Spin</cell><cell>http
://www.secondspin.com/cart.jsp?add=true&trans=buy&condition=used&type=1&price=10.99&id=2525866</cell
></row><row id='10'><cell>Blind Guardian</cell><cell>Follow the Blind</cell><cell>1</cell><cell>12.99
</cell><cell>Second Spin</cell><cell>http://www.secondspin.com/cart.jsp?add=true&trans=buy&condition
=used&type=1&price=12.99&id=875330</cell></row><row id='18'><cell>Blind Melon</cell><cell>Best of Blind
 Melon [Bonus DVD] [Limited Edition]</cell></row></rows>

And the jqGrid call :
$("#table1").jqGrid({
url:'wrap/query.php',
datatype: 'xml',
xmlReader : {
root: "rows",
row: "row",
page: "rows>page",
total: "rows>total",
records : "rows>records",
repeatitems: true,
cell: "cell",
id: "[id]",
},
mtype: 'GET',
colNames:['Artist','Album', 'Quan.','Price','Place','URL'],
colModel :[
{name:'artist', index:'artist', width:55},
{name:'album', index:'album', width:90},
{name:'quanity', index:'quanity', width:80},
{name:'price', index:'price', width:80},
{name:'place', index:'place', width:80},
{name:'link', index:'link', width:150}],
pager: jQuery('#pager'),
rowNum:50,
rowList:[10,20,30],
sortname: 'price',
sortorder: "asc",
viewrecords: true,
imgpath: 'js/themes/coffee/images',
caption: 'Your Search for: <? echo $mSearch; ?>'

Any Ideas?
24/12/2008
13:28
Avatar
akilhoffer
Tulsa, OK
New Member
Members
Forum Posts: 2
Member Since:
24/12/2008
sp_UserOfflineSmall Offline

I have the exact same issue. My js looks good, my xml looks good, and no errors reported in Firebug, but the grid isnt displaying any errors or paging data. How can we troubleshoot an issue like this?

24/12/2008
17:51
Avatar
gpit2286
New Member
Members
Forum Posts: 2
Member Since:
23/12/2008
sp_UserOfflineSmall Offline

Hey -

Fixed my problem. I put the XML response into a validator and "WHOAAAAA!!! ERRRORS".  Simple solution - any field that is going to have any char that is not [a-z][A-Z][0-9]... use CDATA

http://www.w3schools.com/XML/xml_cdata.asp

26/12/2008
10:57
Avatar
akilhoffer
Tulsa, OK
New Member
Members
Forum Posts: 2
Member Since:
24/12/2008
sp_UserOfflineSmall Offline

For me, the problem was my content type not being set properly.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
28 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information