Webservice renvoyant l’erreur interne 500 uniquement à partir d’un appel JQuery

Je reçois une erreur interne 500 lorsque j’appelle de JQuery, pas autrement. Aidez-moi, s’il vous plaît!!!

Appel JQuery

$.ajax({ type: "POST", url: "myWebService.asmx/getnpsTrend", data: jsonData, contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess_, error: OnErrorCall_ }); 

Méthode de service Web:

  [WebMethod] [System.Web.Script.Services.ScriptMethod(UseHttpGet = true)] public List getnpsTrend(ssortingng region, ssortingng client, ssortingng product) {  } 

J'ai essayé toutes les solutions possibles, à l'exception des applications statiques:

  1. Enabled obtenir

  2. Fichier de configuration reconfiguré

Plus de fond ...

  • J'utilise chart.js pour afficher des graphiques
  • Pour rendre les données du graphique dynamics, j'utilise le service Web pour me fournir des données au format JSON. Voici la référence.
  • Cela fonctionne parfaitement si j'appelle directement le service Web. Je me demande donc si l’url fournie dans l’appel de JQuery est erronée! J'ai essayé différentes combinaisons mais rien n'a encore fonctionné! 🙁

Edit: code JQuery complet

  $(document).ready(function () { $("#btn_line_chart").on('click', function () { var fil_reg = $("#ddlRegion").val(); var fil_cli = $("#ddlClient").val(); var fil_prd = $("#ddlProduct").val(); console.log("Inside function"); console.log(fil_reg); var jsonData = JSON.ssortingngify({ jsn_reg: fil_reg, jsn_cli: fil_cli, jsn_prd: fil_prd }); $.ajax({ type: "POST", url: "myWebService.asmx/getnpsTrend", data: jsonData, contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess_, error: OnErrorCall_ }); function OnSuccess_(reponse) { var aData = reponse.d; var aLabels = aData[0]; var aDatasets1 = aData[1]; var aDatasets2 = aData[2]; var data = { labels: aLabels, datasets: [{ label: "My First dataset", fillColor: "rgba(220,220,220,0.2)", strokeColor: "rgba(220,220,220,1)", pointColor: "rgba(220,220,220,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", pointHighlightStroke: "rgba(220,220,220,1)", data: aDatasets1 }, { label: "My Second dataset", fillColor: "rgba(151,187,205,0.2)", strokeColor: "rgba(151,187,205,1)", pointColor: "rgba(151,187,205,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", pointHighlightStroke: "rgba(151,187,205,1)", data: aDatasets2 }] }; var ctx = $("#myChart").get(0).getContext('2d'); ctx.canvas.height = 300; // setting height of canvas ctx.canvas.width = 500; // setting width of canvas var lineChart = new Chart(ctx).Line(data, { bezierCurve: false }); } function OnErrorCall_(repo) { alert("Woops something went wrong, pls try later !"); } }); });  

Apportez les modifications suivantes dans le script Web

  [System.Web.Script.Services.ScriptService] // add top of Class file public class myWebService: System.Web.Services.WebService { [WebMethod(EnableSession = true)] public List getnpsTrend(ssortingng region, ssortingng client, ssortingng product) { //Check if we get All Parameters from Ajax function ie region, client and product // Code } } 

Puis en fonction Ajax

  $.ajax({ url: '../myWebService.asmx/getnpsTrend', data: "{'region': '" + regionvalue + "'}, 'client': '" + clientvalue + "','product': '" + productvalue + "'", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", success: function (data) { if (data != null) { // use data.d value } }, error: function (data) { alert("Error message "); } });