jquery update div as text input is modified

Posted by Piero on Stack Overflow See other posts from Stack Overflow or by Piero
Published on 2010-05-26T10:11:49Z Indexed on 2010/05/26 10:21 UTC
Read the original article Hit count: 204

Filed under:

Hi,

So I have this text input in a form, and I want to update a div as the user types text in the text input.

 <p><label for="movie_name">Film: </label> <input type="text" name="movie_name" class="required" onkeydown="changediv2(this.value)" /></p>

 <p><div id="ajax_update"></div></p>

My js method:

function changediv2(str) {
$('#ajax_update').html(geturl('http://url/search/movie?query='+str));
}

If I type in a browser http://url/search/movie?query=someString, I get some html displayed. But when I call it via this ajax call, nothing happens...

My geturl method:

function geturl(addr) {
 var r = $.ajax({
  type: 'GET',
  url: addr,
  async: false
 }).responseText;
 return r;
}

I cannot see what is wrong in there...

Please help me! :)

© Stack Overflow or respective owner

Related posts about jquery-ajax