Ben Nash Posted April 19, 2014 Share Posted April 19, 2014 I'm working with the Google Feed Api and made a search form to search for rss feeds. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google AJAX Search API Sample</title> <script src="//www.google.com/jsapi?key=AIzaSyAWetejqPLSq_LiLzg2jeJ98QWGiF8ocgQ" type="text/javascript"></script> <script type="text/javascript"> /* * How to find a feed based on a query. */ google.load("feeds", "1"); function OnLoad() { // Query for president feeds on cnn.com var query = "<?= $searchfor ?>"; google.feeds.findFeeds(query, findDone); } function findDone(result) { // Make sure we didn't get an error. if (!result.error) { // Get content div var content = document.getElementById('content'); var html = ''; // Loop through the results and print out the title of the feed and link to // the url. for (var i = 0; i < result.entries.length; i++) { var entry = result.entries[i]; html += '<p><a href="' + entry.url + '">' + entry.title + '</a></p>'; } content.innerHTML = html; } } google.setOnLoadCallback(OnLoad); </script> </head> <body style="font-family: Arial;border: 0 none;"> <form action="play.php" method="POST" /> Query: <input type="text" name="searchfor" /> <input type="submit" name="search" /> </form> <?php if (isset($_POST['search'])) { $searchfor = $_POST['searchfor']; if (empty($searchfor)) { echo"No text entered."; } else { echo'<div id="content">Loading...</div>'; } } ?> </body> </html> This is the code I have but when I search for something e.g. bbc news the text "Loading..." appears and it doesn't show any rss feeds. What is wrong??? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 19, 2014 Share Posted April 19, 2014 Have you checked the console? Quote Link to comment Share on other sites More sharing options...
Ben Nash Posted April 19, 2014 Author Share Posted April 19, 2014 For? ------- Quote Link to comment Share on other sites More sharing options...
Script47 Posted April 19, 2014 Share Posted April 19, 2014 For? ------- The console is a very good debugging tool, it tells you JS errors/warnings, so maybe if you look there and it might shed some light to why it isn't working. 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.