I am having a weird problem. I have a php script that is called by an ajax function that is not placing the html returned the way the data is. Here we go.
- <?php // getMemberVideos.php
- // Get schedule from the database
- include "main.php"; // This is for the id vars only
- $db=mysql_connect($hostname, $idname, $idpass) or die(mysql_errno($db).": ".mysql_error($db));
- mysql_select_db($sdbname);
-
- // Get the Schedule Table
- $sql = sprintf("SELECT category FROM schedule WHERE type = 'Video' ORDER BY category ASC");
- $q = mysql_query($sql);
- $catcnt = 0;
- $lastcat = "";
- $cats = $tm = $em = array();
- $sch = '<ul>'; // start the tablist
- $tbl = '<table width="98%" align="center">';
- while($em = mysql_fetch_array($q)) {
- $cat = $em['category'];
- if (strcmp($cat, $lastcat) != 0) {
- $lastcat = $cat;
- $cats[$catcnt++] = $cat;
- $sch .= '<li><a href="#'.$cat.'">'.$cat.'</a></li>';
- }
- }
- $sch .= "</ul>"; // end the tablist
- for ($i = 0; $i < $catcnt; $i++) { // build the tabs div content
- $sch .= sprintf('<div id="%s">%s',$cats[$i], $tbl);
- $sql = sprintf("SELECT * FROM schedule WHERE type = 'Video' AND category = '%s' ORDER BY category, title ASC", $cats[$i]);
- $q0 = mysql_query($sql);
- while($tm = mysql_fetch_array($q0)) {
- $rmn = $tm['roomname'];
- $cid = $tm['custid'];
- $iml = $tm['picture'];
- $tit = $tm['title'];
- $dsc = $tm['description'];
- $cat = $tm['category'];
- $prv = trim($tm['privacy']);
- $ifm = explode('/',$iml); // Break up the filepath
- $ifc = count($ifm) -1; // Get the count -1
- $ifs = explode('.',$ifm[$ifc]); // Break apart the filename
- $imt = sprintf("http://itssoezy.com/uploads/%s/%s.jpg", $cid, $ifs[0]);
- $r0 = sprintf('<tr><td align="left" width="30%%"><a href="users/broadcast/watcher.php?c=%s&s=%s&p=%s" title="%s"><img align="absmiddle" src="%s" alt="ise" width="64" height="64"><font size="2"> %s</font></a></td>', $cid, $iml, $prv, $dsc, $imt, $tit);
- $r1 = '<td align="left" width="55%"><b><font size="2">'.$dsc.'</font></b></td>';
- $r2 = '<td align="left" width="15%"><b><font size="2">Privacy: '.$prv.'</font></b></td>';
- $sch .= $r0.$r1.$r2.'</tr>';
- }
- $sch .= '</table></div>';
- }
- echo json_encode($sch);
- ?>
This is called by the following jQuery function.
- function MemberVideos() {
- $.ajax({
- url: "iwon/support/getMemberVideos.php",
- type: "POST",
- dataType: 'json',
- cache: false,
- async: false,
- success: function(html) {
- $("#membervideolist").html(html);
- }
- });
- }
In the <head> section I have the jQuery code
$(function() {
$("#cattabs").tabs();
});
In the <body> section I simply use a div to make the tabs
<div id="cattabs"><div id="membervideolist"></div></div>
I traced the network access in Chrome using the JS console and the returned html from the PHP file is:
- "<ul><li><a href=\"#Music\">Music<\/a><\/li><li><a href=\"#Travel\">Travel<\/a><\/li><li><a href=\"#Vehicles\">Vehicles<\/a><\/li><\/ul><div id=\"Music\"><table width=\"98%\" align=\"center\"><tr><td align=\"left\" width=\"30%\"><a href=\"users\/broadcast\/watcher.php?c=6285F178F928&s=uploads\/6285F178F928\/TakilmaRunWork.mp4&p=No\" title=\"This is 3-Gen practicing Takilma Run\"><img align=\"absmiddle\" src=\"http:\/\/itssoezy.com\/uploads\/6285F178F928\/TakilmaRunWork.jpg\" alt=\"ise\" width=\"64\" height=\"64\"><font size=\"2\"> Takilma Run Work Video<\/font><\/a><\/td><td align=\"left\" width=\"55%\"><b><font size=\"2\">This is 3-Gen practicing Takilma Run<\/font><\/b><\/td><td align=\"left\" width=\"15%\"><b><font size=\"2\">Privacy: No<\/font><\/b><\/td><\/tr><\/table><\/div><div id=\"Travel\"><table width=\"98%\" align=\"center\"><tr><td align=\"left\" width=\"30%\"><a href=\"users\/broadcast\/watcher.php?c=TKLM33446655&s=uploads\/TKLM33446655\/IMG_0013.mp4&p=No\" title=\"The California Coast near Santa Barbara From Amtrak coach\"><img align=\"absmiddle\" src=\"http:\/\/itssoezy.com\/uploads\/TKLM33446655\/IMG_0013.jpg\" alt=\"ise\" width=\"64\" height=\"64\"><font size=\"2\"> Coast Starlight<\/font><\/a><\/td><td align=\"left\" width=\"55%\"><b><font size=\"2\">The California Coast near Santa Barbara From Amtrak coach<\/font><\/b><\/td><td align=\"left\" width=\"15%\"><b><font size=\"2\">Privacy: No<\/font><\/b><\/td><\/tr><\/table><\/div><div id=\"Vehicles\"><table width=\"98%\" align=\"center\"><tr><td align=\"left\" width=\"30%\"><a href=\"users\/broadcast\/watcher.php?c=6285F178F928&s=uploads\/6285F178F928\/TL-CLIP0006.MP4&p=No\" title=\"This is my friends Harley I am showing for demo purposes.\"><img align=\"absmiddle\" src=\"http:\/\/itssoezy.com\/uploads\/6285F178F928\/TL-CLIP0006.jpg\" alt=\"ise\" width=\"64\" height=\"64\"><font size=\"2\"> My Friends Harley<\/font><\/a><\/td><td align=\"left\" width=\"55%\"><b><font size=\"2\">This is my friends Harley I am showing for demo purposes.<\/font><\/b><\/td><td align=\"left\" width=\"15%\"><b><font size=\"2\">Privacy: No<\/font><\/b><\/td><\/tr><\/table><\/div>"
Which is exactly what I want. It has the ul for 3 tabs across and then adds the div's for the tabs. When I run this as a standalone it works perfectly! HELP! Maybe I'm too tired and can't see the error. So please need some other eyes.
Thanks a lot.