Uncaught TypeError: response.splice is not a function

0

Personnel could someone help me with the following error.

I am doing an Audit page for a system only that javascript is giving error.

Here'smyfunctioninJS

$(document).ready(function(){$('[name="btn_detalhes"]').click(function () {
        var cadastroId = $(this).attr('CadastroId');
        var patientId = $(this).attr('data-content');
        $.ajax({
            method: 'POST',
            url: '/Formulario/Cadastro/VerificaDiff',
            data: { 'PatientId': patientId, 'CadastroId': cadastroId },
            success: function (response) {
                var t = response.splice(",");
                var t1 = t[0].splice(',');
                var t2 = t[1].splice(',');
                if (t1.length > 0 && t2.length > 0) {
                    $('#msgLoading').fadeIn(0);
                    $('.small.modal.Detalhes').modal({
                        closable: false,
                        blurring: true,
                    }).modal('show');
                    for (var i = 0; i < t1.length; i++) {
                        $('#trInser1').append('<p> ' + t1[i] + ' </p>');
                        $('#tdInser2').append('<p> ' + t2[i] + ' </p>');
                    }
                    $('#msgLoading').fadeOut(0);
                } else {
                    notif({
                        'type': 'error',
                        'msg': 'Não foi encontrado modificações no formulário!',
                        'position': 'center'
                    });
                }
            },
            error: function (response) {
                notif({
                    'type': 'error',
                    'msg': 'Erro na resposta do servidor!',
                    'position': 'center'
                });
            }
        })
    });

    $('.btn_ok').click(function () {
        $("p").remove();
        $('.small.modal.Detalhes').modal('hide');
    });
});
    
asked by anonymous 11.01.2018 / 18:40

1 answer

0

You are trying to use a function in a string (response), the function splice can only be used with Array .

Example of how splice is used, removed from w3schools :

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(2, 0, "Lemon", "Kiwi");
// resultado: Banana,Orange,Lemon,Kiwi,Apple,Mango

In your case, you could use the Split function.

Example of how to use the Split function, removed from w3schools :

var str = "How are you doing today?";
var res = str.split(" ");
// resultado: How,are,you,doing,today?
    
11.01.2018 / 20:37