Woody Posted September 21, 2010 Report Share Posted September 21, 2010 Hi there Ben, Could you please tell me why my code isn't working? (I'm using xampp on my WindowsXP machine.) I have each page loaded in xampp\htdocs. The getforum page works great, but the jQuery function on the index page doesn't want to load the getforum.php. It just displays the heading, not the div. Any help in learning what I'm doing wrong would be greatly appreciated! Thanks. Here is my index.php page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Killersites</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#recentTopics').load("getforum.php"); }); </script> </head> <body> <h1>Recent Forum Topics:</h1> <div id="recentTopics"></div> </body> </html> And here's my getforum.php page: <?php ini_set("display_errors",0); $limit = 5; $file = "http://www.killersites.com/community/index.php?/rss/forums/1-recent-community-activity/"; if ($xml = simplexml_load_file($file)) { echo "<ul>"; foreach($xml->channel->item as $item) { echo "<li><a href='$item->link'>$item->title</a></li>"; $limit--; if($limit==0){break;}; } echo "<li><a href='http://www.killersites.com/community/index.php?app=core&module=search&do=active'>View All Topics</li></ul>"; } else { echo "<strong>Oops! The most recent forum topics cannot be displayed at this time.</strong>"; } ?> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 21, 2010 Report Share Posted September 21, 2010 I'll take a look at this in a bit more detail later tonight... Your jquery.js file exists and is in the correct location, right? In the same folder as index.php? Quote Link to comment Share on other sites More sharing options...
Webkiller Posted September 21, 2010 Report Share Posted September 21, 2010 Was that you just putting killersites in there a forgot the </a>? echo "<li><a href='http://www.killersites.com/community/index.php?app=core&module=search&do=active'>View All Topics</a></li></ul>"; Quote Link to comment Share on other sites More sharing options...
Webkiller Posted September 21, 2010 Report Share Posted September 21, 2010 I'll take a look at this in a bit more detail later tonight... Your jquery.js file exists and is in the correct location, right? In the same folder as index.php? Lets hope the .js file exists that would cause it. Quote Link to comment Share on other sites More sharing options...
Woody Posted September 21, 2010 Author Report Share Posted September 21, 2010 Yeah Ben...the jquery.js file is in place...same folder as index.php. Quote Link to comment Share on other sites More sharing options...
Woody Posted September 21, 2010 Author Report Share Posted September 21, 2010 Hey, Ben...I used the same jquery.js file as I used on the index page of todaystruth.com. I just copied it and renamed it. Could there be a problem with the .js file because of that? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 21, 2010 Report Share Posted September 21, 2010 I'm not seeing any issues with the code, and it works fine for me when I tested it. Just in case, are you absolutely sure your files are named correctly? For example, Windows hides the file extension by default, and there may be a slight chance your jquery file is actually named "jquery.js.js". More info is here: http://www.killersites.com/community/index.php?/topic/3010-cant-open-my-website/page__gopid__16509entry16509 I'm not sure if your issue has anything to do with this, but it's worth checking. Also, you've double checked that Javascript is turned on in your browser, right? I would also try re-downloading the jquery file just in case as well. Quote Link to comment Share on other sites More sharing options...
Woody Posted September 21, 2010 Author Report Share Posted September 21, 2010 OK, Ben...I hate these weird things...thanks for your attention to my problem. When I opened my localhost this a.m. and opened index.php, it is now working as it should, with no changes made since last night! Have you any experience with this sort of behavior? It is very frustrating. I spent HOURS trying to figure out what I was doing wrong! Any light on the subject would be appreciated greatly! Quote Link to comment Share on other sites More sharing options...
Woody Posted September 21, 2010 Author Report Share Posted September 21, 2010 Hey Ben! I just discovered that it is a browser problem. I opened it with GoogleChrome this a.m. and it worked, so I tried it with Firefox, which I was using last night, and it does NOT work. Can you tell me why this would be so? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 21, 2010 Report Share Posted September 21, 2010 I'm not sure. As I said, it works fine (in Firefox) for me. Perhaps you have a addon of some sort that is messing things up? Quote Link to comment Share on other sites More sharing options...
Woody Posted September 21, 2010 Author Report Share Posted September 21, 2010 Ben...I just tried "view page source" on both browsers, and clicking on the jquery.js link in the line <script type="text/javascript" src="jquery.js"></script>. In Chrome, it opens the file...in Firefox it doesn't. Is there a way you know of that I can find out why this is? Thanks for your help. I'll just stop using firefox if I can't figure this out. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 21, 2010 Report Share Posted September 21, 2010 Can you explain what happens when you click the link in Firefox? Quote Link to comment Share on other sites More sharing options...
Woody Posted September 21, 2010 Author Report Share Posted September 21, 2010 The page just "blinked" and nothing else happened...but now it works. I opened the htdocs folder in Firefox and went to Tools > Folder Options > View, and the "Hide extensions for known file types" was already UNchecked...but under the "Manage pairs of web pages and folders" option the "Show and manage the pair as a single file" button was selected, so I changed it to "Show both parts and manage them individually". Now the page works in Firefox also. Could you possibly explain just what that did? I haven't a clue what it is talking about, but it fixed that particular problem, or seemed to. Quote Link to comment Share on other sites More sharing options...
Woody Posted September 21, 2010 Author Report Share Posted September 21, 2010 Ben...maybe what I did (see last post) didn't actually fix anything. I just discovered that if I trail my url with a "/" (127.0.0.1/index.php/), the js doesn't work on either browser, but if I omit the trailing "/", then it works on both. Any thoughts? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 22, 2010 Report Share Posted September 22, 2010 Why would you add a trailing "/" to the URL? That doesn't make sense to me -- adding the "/" may make the browser think that you are looking for a index.php directory, not single file. That could potentially cause issues. I can't really tell you what is going on... as I said, I only know what I see when I test the code in my browser. It works fine for me on my browser when I test it. Quote Link to comment Share on other sites More sharing options...
Woody Posted September 22, 2010 Author Report Share Posted September 22, 2010 Thanks Ben...Just asking the questions made me see that the trailing "/" on the url was indeed making the browser look for a directory rather than a file. I didn't realize that was what it was doing. I just always saw the trailing slash on other urls and thought it was how you did things. I'm that much of a "Newbie" you see. Anyway, thanks again...and thanks for your tutorials on the PHP section of KSU. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 22, 2010 Report Share Posted September 22, 2010 Glad you got it figured out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.