Home Bind data in select multiple with jquery
Reply: 0

Bind data in select multiple with jquery

Gaurav_0093
1#
Gaurav_0093 Published in 2017-12-07 14:09:16Z

I am using select multiple control using selectsize.js here is my control

<div class="default selectize-control multi">
                            <select multiple id="select-email" class="selectize-input items has-options has-items full">
                                @*<option value="0">Zero</option>
                                <option value="1">One</option>
                            </select>
                        </div>

I am trying to bind this control through ajax here is my Ajax code

var selectemailemail = $("#select-email");
        selectemailemail.empty().append('<option selected="selected" value="0" disabled = "disabled">Loading.....</option>');
        $.ajax({
            type: "GET",
            url: "/api/Customer/GetCustomerList",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data)
            {
                console.log('response', data);

                for(var i=0;i<data.length;i++)
                {
                    console.log('data[i].email' + data[i].Email);
                    $("<option value=" + data[i].TokenId + ">" + data[i].Email + ")</option>").appendTo(selectemailemail);


                }
                selectemailemail.multipleSelect('refresh');
            },
            failure: function (response)
            {
                alert(response.responseText);
            },
            error: function (response) {
                alert(response.responseText);
            }
        });
    };

while running ajax codei am getting data in an array here is the data in an array

{Id: 0, ContactNo: null, FirstName: null, LastName: null, Email: "verveshivam@gmail.com ", …}

and i want to try to bind the email value in that selected multiple control using code here is my code

for(var i=0;i<data.length;i++)
            {
                console.log('data[i].email' + data[i].Email);
                $("<option value=" + data[i].TokenId + ">" + data[i].Email + ")</option>").appendTo(selectemailemail);


            }

but it is not binding the value in console it is not showing error in console alsoso how can i bind the value in selected multiple control.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310494 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO