Dropdown not showing properly when using ajax

时间:2017-05-16 09:31:30

标签: javascript php jquery html ajax

In my php code when I am loading directly data through PHP and HTML code and without using ajax working properly i.e select dropdown are showing correctly GUI because I have used js library for Chosen-select

but when I am loading data throuhg ajax and appending to page the code work properly but select tag not loading properly as it is showing simple dropdown why

code for select tag is for ajax and for without ajax also

<select data-placeholder="Choose a Presentation Type" class="form-control 
                          chosen-select col-md-6 " tabindex="3" name="presentation_type">
    <option value="">Choose a Presentation Type</option>
    <option value="Test" >Test</option>
    <option value="Test2" >Test2</option>                                         
</select> 

this is the output with ajax enter image description here

and this is output without ajax enter image description here

May be this is jquery library issue because in load time it generates some html code in page and when I am appending through ajax it's not generate any html code through ajax so what is solution for this

1 个答案:

答案 0 :(得分:0)

reinitialise your chosen for that specific select after you populate it

$('select[name=presentation_type]').chosen();

OR

jQuery('select[name=presentation_type]').chosen();