www.webdeveloper.com
Results 1 to 3 of 3

Thread: Js stopt working for no reason

  1. #1
    Join Date
    Dec 2009
    Posts
    92

    Question Js stopt working for no reason

    Hi all,

    I had a beautiful script written by @rnd me that looks like this:

    Code:
    <body>
    <input  id='inp' /> <select  id='sug' />
    
    <script type='text/javascript'>
    	
    function el(tid) {return document.getElementById(tid);}
    
    function addScript(u){ 
       var head=document.getElementsByTagName('head')[0],
         sc2=document.createElement('script'); sc2.src=u;    
       head.appendChild(sc2);
       setTimeout(function(){ head.removeChild(sc2); sc2=null;}, 20000)
     }//end addScript()
    
    
    function suggest(data){ 
      var sel=el("sug").options; sel.length=0;
      data[1].map(function(a){return a[0];}).map(function(a,b){
      sel[b]=new Option(a);
     });
     sel.size=data[1].length;
    }//end suggeest()
    
    
    el("inp").onkeypress=function(){
      addScript("http://www.google.com/complete/search?hl=nl&callback=suggest&q="+this.value);
    }
    	
    </script>	
    </body>

    This script made it possible to show Google suggestion while typing in an input field. The Google suggestions are retrieved over here:
    http://google.com/complete/search?q=...output=toolbar(These are the suggestions for the word ''house'')

    The problem is that all of the sudden it stopped working! For apparently no reason because Google is still 'providing' the suggestions online. So I have two questions:

    Why is it stopped working? Did Google restrict the suggestions to third parties?

    What do I have to change in the code to make it work again?

    Thanks

  2. #2
    Join Date
    Jan 2009
    Location
    Insanity
    Posts
    1,131
    <input id='inp' /> <select id='sug' /> are missing important stuff like...

    name="" & type="" tags in the <input and the name="" and it has no </select> closing tag to the opening <select...

    The other validation error I find is "http://www.google.com/complete/search?hl=nl&callback=suggest&q=" which is throwing up some errors and when I try to pass it a valid term, I get.

    400. That’s an error.

    Your client has issued a malformed or illegal request. That’s all we know.
    as a response. So how have you determined if Google have not turned it off or moved the resource? Its not the first time they have moved services about without warning.

  3. #3
    Join Date
    Dec 2009
    Posts
    92
    Quote Originally Posted by JunkMale View Post
    So how have you determined if Google have not turned it off or moved the resource? Its not the first time they have moved services about without warning.
    Hi, As I understand Google never put this online as a 'service, free to use'. However since it was online you could refer to it, without breaking any laws I guess.. So there are some web developers who wrote code to make use of it.
    So I think that Google has restricted retrieving the XML file somehow. But I'm sure there is a workaround for this problem since the file is still presented online. However I can't solve this mystery do to a lack of programming skills So if anyone could do me the honer, I would really appreciate it.
    Last edited by yomoore; 12-13-2011 at 08:23 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles