I don't mean to step on your idea, but I think the database method
probably works better. Databases are usually highly optimized to do
text-search and it should be fairly quick. By using the separate JSON
file method, you're just placing all the processing work on the client-
side, which might hinder their experience because it will be slower
for them depending on their computer specs.

Anyway, regardless of which method you're using, the jQuery
Autocomplete plug-in:
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
might be of use for you.

(Sorry, this post does not answer your question of searching in a JSON
object.)

On Jun 1, 11:03 pm, Kristof <kristofstrooba...@gmail.com> wrote:
> Hello, i have just joined this group. First Google group i join !
> I'm not native English speaking so sorry if i make some grammar
> mistakes.
>
> Anyway, the past 2 weeks i've been looking into JSON/AJAX functions of
> jquery.
> Now the reason for me doing that is that I want to make the following:
>
> I want to have an input field that ask you for a code, let's say
> "abc", my script should then automatically search for the price in the
> database, so with an onblur i suppose.
>
> Now i googled/read etc etc, and i came up with a script that worked.
> It ran a PHP script, generated an array according to the SJON standard
> that i found on the official website.
>
> BUT after re-thinking  what I was doing i thought to myself "what if I
> have a database with 10 000 products. I would load a query each time
> to search trough these 10 000 products/items.  So I figured there must
> be a better way. So i came up with the following idea:
>
> lets run the PHP scripts one's a day and generate a .JS file
> containing ALL the products in some sort of array readable for
> $.getJson(). And this is where I get stuck:
> how can I read trough the JS file and only select the price of the
> item of witch I typed in the code "abc" ?
>
> so if I have products.JS generated by PHP-script containing :
> {"channel":{"items":[{"id":"1","prijs":"10","naam":"a"},
> {"id":"2","prijs":"5","naam":"b"},
> {"id":"3","prijs":"22","naam":"c"}]}}
>
> how could I select the "prijs" of product "a" from that JS-file ? Is
> it at all possible and if so how ?
>
> Help would be greatly appreciated !

Reply via email to