Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde, preciso de um help,
Estou tentando executar uma Jgrid, retornando um serviço(.asmx), retorna do banco ok no Chrome porém não alimenta a grid e não da erro.
Segue:
aspx
<div id="dataTables_wrapper">
<table id="jQGridDemo">
</table>
<div id="jQGridDemoPager">
</div>
</div>
**asmx**
private relValidade relVal = new relValidade();
private HttpContext context;
JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
EntRelPrazoValidade entRelPrazoValidade = new EntRelPrazoValidade();
[WebMethod]
[scriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld()
{
DataTable dt = new DataTable();
dt = relVal.CarregaDados();
string json = string.Empty;
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (System.Data.DataRow dr in dt.Rows)row = new Dictionary<string, object>();
foreach (System.Data.DataColumn col in dt.Columns)row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
json = jsSerializer.Serialize(rows);
return json;
}
**js**
$(document).ready(function () {
// debugger;serializeGridData: function (postData) {
return JSON.stringify(postData);
},],
complete: function (jsondata, stat) {
if (stat == "success") {
var thegrid = jQuery("#liste")[0];
var datajson = JSON.parse(jsondata.responseText).d;
thegrid.addJSONData(datajson);
alert(datajson);
}$(".loading").hide();
alert("Error with AJAX callback");
}
},
error: function (xmlHttpRequest, status, err) {$('.valor').html('Ocorreu um erro');
},
serializeGridData: function (postData) {
try {
return JSON.stringify(postData);
} catch (e) {
}
},
//success: function (data, status) { alert(data.d) },
//error: function (xmlHttpRequest, status, err) { alert("Erro") },});
**Formato**
{"cdProduto":"EYA01445","dsProduto":"CARTÃO CIOC CLUB","dsDescricaoClasse":"DISPONIVEL","nrSaldo":6563}
Desde já, obrigado.
Carregando comentários...