如何将JS函数参数转换为字符串?

时间:2020-02-11 13:49:17

标签: javascript jquery

我有一个小问题,当我通过js函数发布参数时,出现错误:未捕获的ReferenceError:未定义SEAL 在HTMLButtonElement.onclick(index.php:1) 我从按钮中收到了SEAL,这是我的代码:

 { "data": "AREA"},
            { "data": "COD" , render: function(data, type, row ) {
                data = "<button type='button' class='btn btn-danger' onclick='callDisableCause(" + data + ','  + row.AREA + ");'><i class='fa fa-trash'></i></button>";
                return data;
              }
                }

这是我在DataTable中呈现的按钮,从中我接收到我需要的数据,因此上面的错误显示“ SEAL未定义” SEAL来自参数“ row.AREA”,我该如何定义它?这是我的功能:

function callDisableCause(id, area){
   var area = JSON.stringify(area);
    var url = "webservices/ws_downtime/ws_disableCause.php"
    $.ajax({
      method: "POST",
      url: url,
      data:{
        id: id,
        area: area
      },
      success: function(result){
        alert(result);
        swal({
              title: "Cuidado!", // titulo do alerta
              text: "Deseja realmente desabilitar essa causa?", //texto apresentado ao cliente no alerta
              icon: "warning", // icone apresentado ('success', 'warning')
              buttons: true, // botoes(possivel personalizar, colocar o texto que melhor se encaixa na situação)
            })
            .then((willDelete) => { // função para pegar o resultado do alerta
              if (willDelete) { 
                // se for verdadeiro ele recarrega o formulario
                $('#mainpages').load('pages/downtime/downtime_admin/downtimeSymptom.php');

              }

               else { 
                 // se for falso volta para a pagina principal
                 $('#mainpages').load('pages/downtime/downtime_admin/downtimeSymptom.php');

              }

            });
      }

    });
}

0 个答案:

没有答案