开发者

How to populate DropDown on page load?

I want to populate a DropDown contro开发者_JAVA技巧l on page load using AJAX. I have the code and it is working, but I am not following as to which event to use.


I'm assuming you're not using a JavaScript framework, but this is simple with jQuery.

$(document).ready(function(){ 
    $("#some_div").load("/dropdown.html", function(){
        [any additional code to make it work]
    });
});

I hope I'm understanding your question correctly.


Firstly, what does the ajax callback return? Partial html formatted as json/xml, or straight up HTML?

One way would be to just re-build the select element and iterate and append option elements, then use the replaceWith method to replace the dropdown. If you have an event on the dropdown, you may need to use liveQuery in order for it to "stick". It would help seeing the code you currently have in order for a definitive answer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜