I am trying to build a fancy jquery dropdown menu ,while making the menu items dynamic by bringing the values of menu items 开发者_开发技巧from database. I am using asp.net and sql server 2005 as my database,Is their any simple article to work this?
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Create a page method that your jquery ajax can call and get results from. Populate the dropdown on click, just remember to do something to let the user know that the values are coming since the database might not respond instantly.
$.ajax({
url: yoururl,
data: { yourfunctiondatavariable},
cache: false,
type: "POST",
success: function (data) {
var markup = "<option value='0'>----Select----</option>";
for (var x = 0; x < data.length; x++)
{
debugger
markup += "<option value=" + data[x].Value + ">" + data[x].Text + "</option>";
}
$("#dropdownname").html(markup).show();
},
error: function (reponse) {
alert("error : " + reponse);
}
});
精彩评论