I have a webservice running locally , which performs queries directly in a database using a string parameter . Here is the result of the query:
ThesecondtimeIhaveajavascript(Jquery)applicationthatconsumeswebserviceviaAjax.AftersomeresearchIcametotheconclusionthattheproblemisXMLencapsulation,asI'mtryingtoconsumeJsonviaAjax.
Jqueryapplicationtryingtoconsumewbeservicec#viaAjax:
$("#btnConsultar").on("click",function(){
var NTalao = $("#campoTalao").val();
$.ajax({
url: "...",
type: "GET",
contentType: "application/json",
data: {"Talao": NTalao},
success: function(data){
$("#resDIV").html(data);
},
error: function(){
alert("Erro!");
}
});
});
Webservice C # Returning Json Encapsulated:
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod]
public string Consultar(string _Talao)
{
Model1 cadastro = new Model1();
clsRecibo recibo = new clsRecibo();
var consulta = from a in cadastro.TB_Recibo
where a.Talao == _Talao
select a;
foreach (var linha in consulta)
{
recibo.Talao = linha.Talao;
recibo.Apresentante = linha.Apresentante;
recibo.TipoServico = linha.TipoServico;
recibo.Status = linha.Status;
recibo.Obs = linha.Obs;
}
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Serialize(recibo);
}
Base question: Is it possible to remove this XML encapsulation from the query? If not, can I query the application differently?
Thank you !!