I have a HTML input that a user will type into. After every key a JQUERY event will grab the text written so far and make an AJAX call that will be picked up by PHP.
I have done this before and its easy to have a PHP script that is called that will then deal with the data passed – eg: db calls and return what is required.
Question – Is it possible to do this using a PHP object? (I’m writting OOP PHP for the first time). Is there some way to combine an AJAX call with a PHP Object or should the PHP end just be a standard function?
thank you
* More info: this function is searching for a location against a database with 6million suburbs/postcodes. Each key a user types a jquery event it trigger that creates an ajax call with the letters typed so far. PHP is called and a SQL query run to return possible locations.
You can combine a PHP object with an AJAX call, but you’d have to explain what you’re trying to do in greater detail for me to determine whether or not it would help you.
It sounds like you just want an AJAX call that is invoked after say, 500ms of a user not giving input to the text box or whatever. That seems like a standard PHP update function.
Based on what you’ve stated so far, I would suggest you just go with the AJAX; have it proc off an onKeyUp, onKeyPress, or whatever you want, and then run some PHP.
Recall that you can create a timer in many fashions; just search around here. You probably don’t want to use AJAX for each key stroke.
OnKeyUp JavaScript Time Delay?
Hope that helps.