yii2中的jquery对话框

I have a js in yii2 like this :

<?php
$getDetailItem = \Yii::$app->getUrlManager()->createUrl(['it/request/get-item-detail']);

$js = <<<JS
var \$pop = $("input[type='checkbox'][name='ItemRequest[id][]']");
$("input[type='checkbox'][name='ItemRequest[id][]']").click(function(e){
    $.ajax({
            url : '$getDetailItem',
            type : 'post',
            data : {id : $(this).val()},
            dataType : 'text',
            success : function(response){
                krajeeDialog.confirm("Your Choice : <br>" +

                    response

                , function (result) {
                if (result) {
                    alert('Anda memilih Item : ' + response);
                }
            });
        }
    });
});
JS;
$this->registerJs($js)
?>

if you can see in the line :

  $getDetailItem = \Yii::$app->getUrlManager()->createUrl(['it/request/get-item-detail']);

will be produce a json like this :

[{
   "id": "1",
   "item_request_id": "1",
   "nama_detail": "Create Login Novell"
}, {
   "id": "2",
   "item_request_id": "1",
   "nama_detail": "Create Email Baru"
}, {
   "id": "3",
   "item_request_id": "1",
   "nama_detail": "Disable / Hapus Login Novell"
}, {
   "id": "4",
   "item_request_id": "1",
   "nama_detail": "Disable / Hapus Email"
}]

My question is, how to display the response.nama_detail in dialog as checklistbox ?

I use thi krajee plugin : kartik / krajee

Then user can choose the items nama_detail

Any help it so appreciate...

Window prompt

Try parsing that JSON response and format data by your needs by looping through array you will get, I used jquery each method for this.

Hopefully I did not make any misstake there, this is not tested, if you find any error, please feel free to comment or edit.

        // ...
        success : function(response){
            var parsed = JSON.parse(response);
            var output = "";
            $.each(parsed, function(index, value){
                output .= value['nama_detail'] . ", ";
            });
            krajeeDialog.confirm("Your Choice : <br>" +

                output

            , function (result) {
            if (result) {
                alert('Anda memilih Item : ' + response);
            }
        });
        // ...