使用jquery ajax添加大数据时出现HTTP错误

时间:2011-07-27 05:49:57

标签: javascript ajax jquery

我在jqgrid中显示ajax时创建了一个很好的html / javascript程序。但就在最近,我注意到当我尝试保存大量或大量数据以保存到我的表格行时,它会返回http:error

当我能成功保存少量线路时,我真的不明白什么是错的。有人告诉我,这是我的html / javascript有问题,因为当我尝试使用delphi(我用来创建我的webservice)跟踪它时,它不会进入我的代码(保存多行时),并且如果我将保存少于10行数据将进入我的代码(跟踪中没有错误)。这是我发送到我的webservice / html请求的数据:

{
"SessionID":"66KuzRH1w1sWCM188q4k8BTJb5ijG81v",
"operation":"add",
"transaction_date":"7/27/2011",
"supplier_id":"10000000108",
"wood_specie_id":"1",
"lines":[
     {"plank_number":"1","thickness":"4","width":"6","length_t":"8","quantity":"1","board_foot":"16.00","wood_classification_id":"1","price":"15"},
     {"plank_number":"2","thickness":"45","width":"6","length_t":"8","quantity":"1","board_foot":"180.00","wood_classification_id":"1","price":"15"},

     .
     .
     .
     .
     {"plank_number":"22","thickness":"3","width":"6","length_t":"8","quantity":"1","board_foot":"12.00","wood_classification_id":"1","price":"15"},
     {"plank_number":"23","thickness":"4","width":"6","length_t":"7","quantity":"1","board_foot":"14.00","wood_classification_id":"1","price":"15"}
   ],
"scaled_by":"JAYSON","tallied_by":"TALLIED BY","checked_by":"CKECKED BY","total_bdft":"582.84","final":""
}

这是添加我的行数据的代码:

function tallyAddData(){
  var datas = {
    "SessionID": $.cookie("SessionID"),
    "operation": "add",       
    //"transaction_num":$('#tallyNo').val(),
    "transaction_date":$('#tallyDate').val(),
    "supplier_id":$('#supplierInput').attr("name"),
    "wood_specie_id":$('#woodSpecie').attr("name"),   
    "lines":plank_data,
    "scaled_by":$('#tallyScaled').val().toUpperCase(),
    "tallied_by":$('#tallyTallied').val().toUpperCase(),
    "checked_by":$('#tallyChecked').val().toUpperCase(),
    "total_bdft":$('#tallyTotal').val(),
    "final":"",
  };
  alert(JSON.stringify(datas));  
  $.ajax({
    type: 'GET',
    url: 'processjson.php?' + $.param({path:'update/tallyHdr',json:JSON.stringify(datas)}),
    dataType: primeSettings.ajaxDataType,
    success: function(data) {
      if ('error' in data)
      {
        showMessage('ERROR: ' + data["error"]["msg"]);
      }
      else{
        $('#tblTallyHdr').trigger('reloadGrid'); 
      }
    }
  });
}  

1 个答案:

答案 0 :(得分:1)

您正在使用Query字符串传递数据 - 查询字符串大小有限(http://en.wikipedia.org/wiki/Query_string) 我建议将数据作为帖子传递:

$.ajax({
  type: 'POST',
  url: url,
  data: data,
  success: success,
  dataType: dataType
});

您还可以阅读有关Jquery帖子的信息(http://api.jquery.com/jQuery.post/)