tags:

views:

71

answers:

1

In my application i need to pass one argument to controller through ajax call on textbox keyup. through submit its wotking but i need thro keyup and ajax is must. Anyone plz explain using small sample

Thanks,

A: 

You can do something like this, if you are using prototype:

<input type="text" id="element_to_observe">

<script type="text/javascript">
Event.observe($('element_to_observe'), 'keyup', function(event) {
var element = Event.element(event);
new Ajax.Request('/controllerName/action/' + element.value, { // your argument
     asynchronous :true,
     onSuccess : doSomething, // your function to execute after response
     evalScripts :true
    });
});
function doSomething(response) {
}
</script>
Maxim