Reputation: 14159
I want to populate a DropDown control on page load using AJAX. I have the code and it is working, but I am not following as to which event to use.
Upvotes: 1
Views: 2163
Reputation: 7922
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.
Upvotes: 1
Reputation: 186562
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.
Upvotes: 0