我对返回的类型为 void 的 c#Web服务方法进行了Jquery ajax调用,而调用响应变为错误,而不是成功。 有什么解决办法
这是代码,
jQuery ajax调用:
$.ajax({
type: "POST",
url: "~/MyWebService.asmx/SCheduleDetailsGet",
data: Data,
contentType: "application/json; charset=utf-8",
dataType: "json",
//async: false,
//global: false,
success: function (response) {
debugger;
},
error: function (data, xhr, error) {
debugger;
return false;
}
});
C#Web服务方法:
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)]
public void SCheduleDetailsGet(int LoginUserID,int ResumeSearchId,string Flag)
{
try
{
DataSet ds = new DataSet();
ds = RHSCheduleGet(LoginUserID, ResumeSearchId, Flag);
object _jsonReturn = null;
object jSonString = null;
System.Web.Script.Serialization.JavaScriptSerializer jSearializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
_jsonReturn = JsonConvert.SerializeObject(ds.Tables[0]);
_jsonReturn = "{\"aaData\":" + _jsonReturn + "}";
Context.Response.Write(_jsonReturn);
}
catch (Exception ex)
{
Context.Response.Write("-2");
}
}