{"id":886,"date":"2006-12-07T22:30:29","date_gmt":"2006-12-08T06:30:29","guid":{"rendered":"http:\/\/cephas.net\/blog\/2006\/12\/07\/ajaxautocompleter-is-not-a-constructor\/"},"modified":"2006-12-07T22:30:29","modified_gmt":"2006-12-08T06:30:29","slug":"ajaxautocompleter-is-not-a-constructor","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2006\/12\/07\/ajaxautocompleter-is-not-a-constructor\/","title":{"rendered":"Ajax.Autocompleter is not a constructor"},"content":{"rendered":"<p>Using <a href=\"http:\/\/script.aculo.us\/\">script.aculous<\/a> to create some cool effects on your website? Ever get this error message?<\/p>\n<blockquote><p>\nAjax.Autocompleter is not a constructor\n<\/p><\/blockquote>\n<p>All of the results I <a href=\"http:\/\/www.google.com\/search?q=ajax.autocompleter+is+not+a+valid+constructor&#038;ie=utf-8&#038;oe=utf-8&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a\">found on Google<\/a> suggested that the solution to the problem was to make sure that you were including controls.js (which is where the <a href=\"http:\/\/wiki.script.aculo.us\/scriptaculous\/show\/Autocompletion\">autocompletion<\/a> stuff lives in script.aculous).  If you checked and double checked that you have controls.js (or that you&#8217;re including scriptaculous.js which itself includes controls.js), then your problem could be that you included <a href=\"http:\/\/prototype.conio.net\/\">prototype.js<\/a> twice. Example:<\/p>\n<pre>\r\n&lt;script type=\"text\/javascript\" src=\"prototype.js\"&gt;&lt;\/script&gt;\r\n&lt;script type=\"text\/javascript\" src=\"scriptaculous.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n  function createAC() {\r\n    new Ajax.Autocompleter('mytextbox', 'myautocomplete', \r\n      'autocomplete\/url', {});\r\n  }\r\n&lt;\/script&gt;\r\n&lt;input type=\"text\" id=\"mytextbox\" name=\"username\" value=\"\" \/&gt;\r\n&lt;div id=\"myautocomplete\" class=\"autocomplete\"&gt;&lt;\/div&gt;\r\n&lt;a href=\"#\" onclick=\"createAC(); return false;\"&gt;start autocomplete&lt;\/a&gt;\r\n&lt;script type=\"text\/javascript\" src=\"prototype.js\"&gt;&lt;\/script&gt;\r\n<\/pre>\n<p>Why?  Prototype defines a class &#8216;Ajax&#8217;:<\/p>\n<pre>\r\nvar Ajax = {\r\n  getTransport: function() {\r\n...\r\n<\/pre>\n<p>and then Script.aculous extends that class:<\/p>\n<pre>\r\nAjax.Autocompleter = Class.create();\r\nObject.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {\r\n...\r\n<\/pre>\n<p>So including prototype.js a second time blows away the class defined by Script.aculous.  Really easy to fix, but if you&#8217;re working on a large team, make sure that prototype.js is only included once on every page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using script.aculous to create some cool effects on your website? Ever get this error message? Ajax.Autocompleter is not a constructor All of the results I found on Google suggested that the solution to the problem was to make sure that you were including controls.js (which is where the autocompletion stuff lives in script.aculous). If you &hellip; <a href=\"https:\/\/cephas.net\/blog\/2006\/12\/07\/ajaxautocompleter-is-not-a-constructor\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Ajax.Autocompleter is not a constructor<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,15],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/886"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=886"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/886\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}