Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

98
Visualizações
jqgrid json data array insert

In jqgrid, the part checked in the checkbox is brought into an array and inserted into the DB through VO.

I got the row data checked in jqgrid multiselect and pushed it into the declared array.

objGrid.click(function(){

            var data = objGrid.jqGrid('getGridParam','selarrrow');
            for(var i =0; i<data.length; i++)
            {

                empsl = objGrid.jqGrid('getCell', data[i], 'empno');
                /* empsl = JSON.parse(empsl); */
                arry.push(empsl);
            }


            test = JSON.parse(arry);
            //test = JSON.stringify(arry);

            console.log(test);


        });
},
        
        buttons : {
            "저장":function() {        
                console.log(typeof arry);
                console.log("insert data",arry);
                
                 if (isRunning) {
                    alert($.message.common.notification.wait);
                    return;
                }
                isRunning = true; 
            
                    $.post("./CheckHoliday/addCheckHolidayData"
                            , {empsl:arry} 
                            , function(data){
                                if (data > 0) {
                                    alert("has been saved.");
                                    closeDialogFunc();
                                    CheckHolidayListRefresh();

When I convert to JSON.stringify and press the save button, it comes in as an array well, but as you can see, even parentheses and quotation marks are entered as it is, and an error occurs.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '["10010","10010","10049"],
'Y'
)' at line 7

So, if you think you need to change it to JSON.parse(arry); and convert it to parse

If only one data is selected in the checkbox, it will be saved successfully, but if more than one checkbox is selected,

Uncaught SyntaxError: Unexpected token , in JSON at position 5 at JSON.parse () at HTMLTableElement.eval (eval at (jquery-1.8.3.js:564), :102:17) at HTMLTableElement.dispatch (jquery-1.8.3.js:3058) at HTMLTableElement.eventHandle (jquery-1.8.3.js:2676)

This error pops up in the developer tools console window, but I can't seem to put it into an array.

The end goal is to put the selected data into an array.

INSERT INTO HRS_CHECKHOLIDAY (
EMPNO
, EMPSL
, USEYN
) VALUES (
${empno},
${empsl},
'Y'
)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Isn't arry an object? So you cannot JSON.parse(arry) and you must get an error. Stringify arry then post the string. That should work.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda