Googlebot crawls parameter to Ajax.Autocompleter

I’m using the autocomplete plugin for Rails, and have this code in all
pages (within tags):

var product_title_auto_completer = new
Ajax.Autocompleter(‘product_title’, ‘product_title_auto_complete’,
‘/store/auto_complete_for_product_title’, {})

This line is generating errors with Googlebots. Apparently trying
Googlebot is trying to crawl the url:
‘/store/auto_complete_for_product_title’ which is defined only in this
ajax call.

I’m assuming Googlebot is parsing the text and seeing the url
(parameter) as a link to try, and results in a 500 error. Any ideas
how I can refactor this out of this context so Googlebot won’t see it?


Anthony E.
408-656-2473
http://anthony.ettinger.name

My approach would be to first ensure the action does not throw an
error when visited directly (non-ajax) by any browser or bot.

In your ajax-only action:
redirect_to :controller => ‘some_controller’, :action => ‘some_action’
unless request.xhr?

or possibly (?)

respond_to do |wants|
wants.html { redirect_to(…etc…) }
wants.js
end

You could then use robots.txt to encourage bots not to crawl that
link.