Skip to content
Advertisement

Get Id From AJAX Response And Use The Id For Select2

I write HTML code in controller

JavaScript

And then in view, I am trying to get rolesForEdit id and use it for select2. It doesn’t work with this way. Any solution?

JavaScript

Advertisement

Answer

Your server return json as response so add dataType: 'json' to your ajax call. Then , append data return to your dataUserElement i.e : data.html and finally intialize your select2 .

Demo Code :

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement