2012-08-02 3 views
0

객체를 반환하는 코드를 디버그하고 디버깅하는 데 도움이되고 싶습니다. 나는 jquery와 javascript를 배우는 초보자이며,이 문제를 디버깅 할 수는 없다. 콘솔에서 출력을 출력 할 때 객체를 얻지 만 모든 데이터가 있습니다. 일어날 것으로 예상되는 것은 id가 actionrow에 전달되고 이것이 db에 대한 ajax 호출을 수행한다는 것입니다. 누군가가 코드를 점검하고 명백한 오류를 지적 할 수 있다면 고맙겠습니다. oblect는 console.log (datarow)에서 출력됩니다. 코드에서. 많은 감사javascript 객체 도움이 필요합니다.

내가 그리드 jqxWidgets를 사용하고 데이터는

// action row. 
    $("#actionrowbutton").bind('click', function() { 
    var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex'); 
    var datarow = $("#jqxgrid").jqxGrid('getrowdata', selectedrowindex); 
    var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; 

    if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 
     var rows = $('#jqxgrid').jqxGrid('getrows', selectedrowindex); 
     var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex); 
     //var service = datarow; 
      console.log(datarow); 

    $("#jqxgrid").jqxGrid('actionrow', id); 

    //Open action dialog window 
    $("#actionWindow").dialog({ 
    //title: 'action error', 
     resizable: false, 
     modal: true, 
     position: ['center', 'center'], 
      buttons: { 
      "Ok": function() { 
       $(this).dialog("close"); 

    $('#jqxgrid').jqxGrid('refreshdata'); 
    }, 
       Cancel: function() { 
    $(this).dialog("close"); 

    //$('#jqxgrid').jqxGrid('refreshdata'); 
    } 
    } 
}); 
    } 
}); 


actionrow: function (actrowid) { 
      // synchronize with the server - send action command 
      var data = "action=true&id=" + actrowid; 
      $.ajax({ 
     dataType: 'json', 
     url: 'data.php', 
     data: data, 
     success: function (data, status, xhr) { 
     // action command is executed. 
     } 
     });       
     } 

답변

1

나는 jqxGrid 위젯에 익숙하지 않아요하지만 난 그게 더 읽을 수 있도록 코드를 포맷.

// action row. 
     $("#actionrowbutton").bind('click', function() { 
      var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex'); 
      var datarow   = $("#jqxgrid").jqxGrid('getrowdata', selectedrowindex); 
      var rowscount  = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; 

      if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 
       var rows = $('#jqxgrid').jqxGrid('getrows', selectedrowindex); 
       var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex); 
       //var service = datarow; 
       console.log(datarow); 

       $("#jqxgrid").jqxGrid('actionrow', id); 

       //Open action dialog window 
       $("#actionWindow").dialog({ 
        //title: 'action error', 
        resizable: false, 
        modal: true, 
        position: ['center', 'center'], 
        buttons: { 
         "Ok": function() { 
          $(this).dialog("close"); 
          $('#jqxgrid').jqxGrid('refreshdata'); 
         }, 
         Cancel: function() { 
          $(this).dialog("close"); 
          //$('#jqxgrid').jqxGrid('refreshdata'); 
         } 
        } 
      }); 
     } 
    }); 


    actionrow: function (actrowid) { 
     // synchronize with the server - send action command 
     var data = "action=true&id=" + actrowid; 
     $.ajax({ 
      dataType: 'json', 
      url: 'data.php', 
      data: data, 
      success: function (data, status, xhr) { 
      // action command is executed. 
      } 
     });       
    } 

다시 살펴본 후 질문이 있습니다. "actionrow"는 jqxgrid 객체의 함수 또는 메서드입니까? 그렇지 않으면 다음과 같이 작성해야합니다.

function actionrow(actrowid) { 
    // synchronize with the server - send action command 
    var data = "action=true&id=" + actrowid; 
    $.ajax({ 
     dataType: 'json', 
     url: 'data.php', 
     data: data, 
     success: function (data, status, xhr) { 
     // action command is executed. 
     } 
    });       
} 

if 문과 같이 호출합니다.

actionrow(id); //not $("#jqxgrid").jqxGrid('actionrow', id); 
+0

Damian, 죄송합니다. 잠시 동안 js를 해본 적이 있으 십니다. 그리고 답이 맞습니다. 나는 틀림없이 나를 깊이 내버려 둡니다. 코드를 어떻게 수정합니까? 감사합니다 – user1532468

+0

@ user1532468 - 아니요. 미안 해요. 게시물을 더 명확하게 읽어야합니다. 위젯을 사용하고 있음을 확인하지 마십시오. 내가 쓴 것은 잘못되었습니다. 다시 한번 살펴보고 편집 해 보겠습니다. – Damian

+0

Damian. 액션 로우는 너무 아약스를 포함하고 있습니다. 줄은 jqxGrid 매개 변수로이 경우 ajax에 전달할 ID를 나타냅니다. 그러나 data.php는 아무 일도 일어나지 않습니다. 아무것도 방화범이나 어떤 에코 명령 등을 통해 다시오고있다 감사합니다 Logged – user1532468

관련 문제