简体   繁体   中英

Whats the best way to load an HTML select with JQuery from C# WCF?

I know at least 1 long way to do it, but I figured I might as well ask.

I have a bunch of values in a C# WCF Service (I could make it into an array, dictionary, etc)

I would like to make an AJAX call from JQuery that will consume the service and load the html select.

I was thinking of returning an IEnumerable from the WCF service, and loop through them in JQuery, adding s to my select.

Is there a better way to do this?

Is there some JQuery command that will consume an array-like structure from WCF and load the box for me? I'm not looking for AJAX code, only JQuery code to load the select, and a recommendation of types to use.

您可以使用jQuery模板http://api.jquery.com/jQuery.template/

It looks like this would do pretty much what I've explained. Is it the best way?

http://www.joe-stevens.com/2010/02/23/populate-a-select-dropdown-list-using-jquery-and-ajax/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM