开发者

Using jquery fetching data from DB and filling the dropdowns

I hav开发者_开发技巧e three dropdowns say "country" , "state" , "city". The items of country dropdown should get fetched from db. And the state dropdown items should also fetched from DB according to country selection. I need this to be done in Jquery. Can anyone help out??


You can use the .post or .get functions to retrieve data from a server-side script. Your server-side script will have to query the database and return the required data.

You can add a change event to the dropdown (I'm assuming it's a select element) and fire a .post or .get request in the event handler.

It's difficult to help you in any more detail than that without seeing what you've already got and what you've already tried.


Considering you are using the better-half of a website, the serverside, You need to call a Server-side script like a .php file to execute the DB queries and then echo the result to the Client-side, you can make ajax calls to the script to fetch the data and load it into a Select DOM tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜