I am thinking about two drop down list, one is depended on another. Both drop down list have values from database. In this case which one is the best way.
Retrieve all values from database using plain PHP then store them in javascript variable, later search for second drop down list value (if first drop down list's value changes)in the javascript (array) variable.
If first drop down list's value changes then retrieve values for second drop down list from database using AJAX(jQuery).
It depends on many things.
You must have to show first dropdown by fetching data from database,
if data for each selected record from dropdown one is big then get it using ajax else make js variables and populate it using javascript on select of first dropdown.
As per your criteria it will be best for your to go with the Ajax late loading, that will make your page load fast while loading and you can get data for other dropdown using ajax.
The two alternatives that you've indicated has pros and cons, the decision depends on how this pros and cons affects your application:
Retrieve all values from database using plain PHP then store them in javascript variable, later search for second drop down list value (if first drop down list's value changes)in the javascript (array) variable.
Pros:
Cons:
If first drop down list's value changes then retrieve values for second drop down list from database using AJAX(jQuery).
Pros:
Cons:
Personally I prefer method 2 if the amount of data is relatively big and the performance is not a must.