Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

97
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda