mboyaci / google-ajax-examples

Automatically exported from code.google.com/p/google-ajax-examples
0 stars 0 forks source link

google object not found error #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Code : 

<!--
  Copyright (c) 2008 Google Inc.

  You are free to copy and use this sample.
  License can be found here: 
http://code.google.com/apis/ajaxsearch/faq/#license
-->

<!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="http://www.google.com/jsapi?key=<<INSERT KEY>>"></script>
    <script type="text/javascript">
    /*
    *  The SearchControl manages searchers and draws a UI for them.  
However,
    *  searchers can be used by themselves without the SearchControl.  
This is
    *  called using a "Raw Searcher".  When doing this, you must handle 
and draw
    *  the search results manually.
    */

    google.load('search', '1');

    var imageSearch;

    function addPaginationLinks() {
      // The cursor object has all things to do with pagination
      var cursor = imageSearch.cursor;
      var curPage = cursor.currentPageIndex; // check what page the app is 
on
      var pagesDiv = document.createElement('div');
      for (var i = 0; i < cursor.pages.length; i++) {
        var page = cursor.pages[i];
        if (curPage == i) { // if we are on the curPage, then don't make a 
link
          var label = document.createTextNode(' ' + page.label + ' ');
          pagesDiv.appendChild(label);
        } else {
          // If we aren't on the current page, then we want a link to this 
page.
          // So we create a link that calls the gotoPage() method on the 
searcher.
          var link = document.createElement('a');
          link.href = 'javascript:imageSearch.gotoPage('+i+');';
          link.innerHTML = page.label;
          link.style.marginRight = '2px';
          pagesDiv.appendChild(link);
        }
      }

      var contentDiv = document.getElementById('content');
      contentDiv.appendChild(pagesDiv);
    }

    function searchComplete() {
      // Check that we got results
      if (imageSearch.results && imageSearch.results.length > 0) {
        // Grab our content div, clear it.
        var contentDiv = document.getElementById('content');
        contentDiv.innerHTML = '';

        // Loop through our results, printing them to the page.
        var results = imageSearch.results;
        for (var i = 0; i < results.length; i++) {
          // For each result write it's title and image to the screen
          var result = results[i];
          var imgContainer = document.createElement('div');

          var title = document.createElement('div');
          // We use titleNoFormatting so that no HTML tags are left in the 
title
          title.innerHTML = result.titleNoFormatting;

          var newImg = document.createElement('img');
          // There is also a result.url property which has the escaped 
version
          newImg.src = result.tbUrl;

          imgContainer.appendChild(title);
          imgContainer.appendChild(newImg);

          // Put our title + image in the content
          contentDiv.appendChild(imgContainer);
        }

        // Now add the paging links so the user can see more results.
        addPaginationLinks(imageSearch);
      }
    }

    function OnLoad() {
      // Our ImageSearch instance.
      imageSearch = new google.search.ImageSearch();

      // Restrict to extra large images only
      imageSearch.setRestriction
(google.search.ImageSearch.RESTRICT_IMAGESIZE,

google.search.ImageSearch.IMAGESIZE_MEDIUM);

      // Here we set a callback so that anytime a search is executed, it 
will call
      // the searchComplete function and pass it our ImageSearch searcher.
      // When a search completes, our ImageSearch object is automatically
      // populated with the results.
      imageSearch.setSearchCompleteCallback(this, searchComplete, null);

      // Find me a beautiful car.
      imageSearch.execute("Subaru STI");
    }
    google.setOnLoadCallback(OnLoad, true);
    </script>
  </head>
  <body style="font-family: Arial;border: 0 none;">
    <div id="content">Loading...</div>
  </body>
</html>

1. Used the same code got the error saying google object is not defined 
script error and there was no display for the same.
2.
3.

What is the expected output? What do you see instead?
The expected output should be the image which should be listed in the page.

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by rajamani...@gmail.com on 25 Jan 2009 at 8:35

GoogleCodeExporter commented 9 years ago
I could not reproduce the bug.

What browser are you using?

Original comment by lisba...@gmail.com on 5 Feb 2009 at 5:14

GoogleCodeExporter commented 9 years ago
Internet Explorer (IE). I appriciate your great work on Google Ajax. I really 
like 
the code and the flexiblity with other applications. Great!!!

Original comment by rajamani...@gmail.com on 5 Feb 2009 at 5:21

GoogleCodeExporter commented 9 years ago
I am getting the exact same bug.  I think it might be deadlocking?

Original comment by sdowni...@gmail.com on 15 Apr 2009 at 11:19

GoogleCodeExporter commented 9 years ago
No its working perfectly now... 

Original comment by rajamani...@gmail.com on 16 Apr 2009 at 12:05

GoogleCodeExporter commented 9 years ago
sdownie87 --

Please provide a link to your page that is experiencing this behavior.

Thanks,
Ben

Original comment by lisba...@google.com on 20 Apr 2009 at 11:07