what to use for this?

what to use for this?

hello, so i'm still practicing my jquery skills.
so i decided to make a "shopping-cart". Basicly i just want to do the following

i have an inputfield where you have to input a code lets say "abc". THen it should get the price of that particular item out of the database and print it on the same line, lets say in a table.

So i have read a lot and came across $.ajax() (see my previous topic) but i have read a lot about .json? aswell, and i'm confused what to use and what's the difference exactly? with the $.ajax() it's not totally clear on how i'm gonna do this.

As i understand i should make an HTML-page with a form on it. Than i should make a function onclick or something that with the ajax goes to a PHP file where i then do a select-query and returns is value ? I then store it in a cookie ?

Anyway who could help me to start ? so i don't have to go blind on this one. THanks in advance, Kristof

PS i'm not native english speaking so i apologize for any ridiculous typo's.