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:
Enabled obtenir
Fichier de configuration reconfiguré
Plus de fond ...
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 "); } });