Rayhaan Jaufeerally
Rayhaan Jaufeerally

Reputation: 359

Making large text box for ajax search

I am making an AJAX application where the user can input the name of a movie and the results from the database will be loaded through jquery from a PHP API, However I am unsure how to implement a text box that will:

(a) Be the focus of attention on the page (i.e. quite large with a glow around it)

(b) automatically execute a function that uses jquery to make an ajax request on every time a letter is entered (kind of like google instant)

Any suggestions would be very greatly appreciated, thanks, RayQuang

Upvotes: 1

Views: 558

Answers (2)

UserZer0
UserZer0

Reputation: 1501

If your using jQuery use the .keyup function and then put your code that gets something from your php script inside that function or do what I do and have your getting done by another function and call that from inside the .keyup function like this:

 function getData(){
            data=$('#textareaid').val();
            $.post('http://example.come/ajaxcontroller.php', {data: data},
            function(data) {// Proccess returned ajax here, you could also use one of the ajax functions instead of .post});
          }

$(document).ready(function() {              
$('#textareaid').keyup(function(e) { getData();}
}

As for the glow, either use css to make a larger 3d border around your textarea (http://www.w3schools.com/css/css_border.asp) or wrap it in a div and make a background that accomplishes the specific effect your looking for.

Upvotes: 1

KJ Saxena
KJ Saxena

Reputation: 21848

a) For the glow, will an outline or a border do?

b) Use an <textarea> tag and trap its onchange event to send the AJAX request each time. You can make the textarea as large as you want by defining rows and cols

Upvotes: 1

Related Questions