jqueryajax到asmxweb方法获取错误作为响应
好的,我就是这么做的: 客户:jqueryajax到asmxweb方法获取错误作为响应,jquery,asp.net,ajax,web-services,asmx,Jquery,Asp.net,Ajax,Web Services,Asmx,好的,我就是这么做的: 客户: function AjaxCall(url, method, data, OnSuccessFunction, OnErrorFunction) { var ajaxData = data; ajaxData = JSON.stringify(ajaxData); var ajaxURL = url + "/" + method; $.ajax({ type: "POST", url: ajaxURL
function AjaxCall(url, method, data, OnSuccessFunction, OnErrorFunction) {
var ajaxData = data;
ajaxData = JSON.stringify(ajaxData);
var ajaxURL = url + "/" + method;
$.ajax({
type: "POST",
url: ajaxURL,
data: ajaxData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
OnSuccessFunction.apply(this, arguments);
},
error: function () {
$('.ProgressBar').hide();
OnErrorFunction.apply(this, arguments);
}
});
}
$(document).ready(function () {
AjaxCall("http://localhost:34714/WebService1.asmx", "GetChart", { filename: 'excel-demo.xlsx', sheet: 'chart_param' }, GetTradingViewSuccess, GetTradingViewError)
});
var GetTradingViewSuccess = function (data) {
}
var GetTradingViewError = function (jqXHR, textStatus, errorThrown) {
}
asmx:
使用系统;
使用System.Collections.Generic;
使用系统数据;
使用System.Data.OleDb;
使用System.Linq;
使用System.Web;
使用System.Web.Script.Services;
使用System.Web.Services;
使用WebApplication2.class;
命名空间WebApplication3
{
///
///WebService 1的摘要说明
///
[WebService(命名空间=”http://tempuri.org/")]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
//要允许使用ASP.NET AJAX从脚本调用此Web服务,请取消注释以下行。
//[System.Web.Script.Services.ScriptService]
公共类WebService 1:System.Web.Services.WebService
{
[System.Web.Script.Services.ScriptMethod()]
[网络方法]
公共字符串add()
{
返回“sd”;
}
[WebMethod(EnableSession=true)]
公共图表GetChart(字符串文件名、字符串表)
{
图表c=新图表();
//做点什么
返回c;
}
}
}
web配置:
<?xml version="1.0"?>
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
</configuration>
500(内部)
服务器错误)发送@jquery-1.7.2.min.js:4f.extend.ajax@
jquery-1.7.2.min.js:4AjaxCall@Common.js:5(匿名函数)@
chart.html:15o@jquery-1.7.2.min.js:2p.fireWith@
jquery-1.7.2.min.js:2e.extend.ready@
jquery-1.7.2.min.js:2c.addEventListener.B@jquery-1.7.2.min.js:2
错误抛出“内部服务器错误”
我将断点放在asmx文件-GetChart webmethod中,但从未达到它。
我做错了什么?//要允许使用ASP.NET AJAX从脚本调用此Web服务,请取消对以下行的注释。
取消该行下面的注释
/[System.Web.Script.Services.ScriptService]
变成
[System.Web.Script.Services.ScriptService]
//要允许使用ASP.NET AJAX从脚本调用此Web服务,请取消注释以下行。
取消该行下面的注释
/[System.Web.Script.Services.ScriptService]
变成
[System.Web.Script.Services.ScriptService]
<?xml version="1.0"?>
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
</configuration>