Jquery Ajax调用Webservice 报错500

kuawai kuawai 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这个是我用来调用WebService的代码。
$.ajax({
type: 'POST',
url: "WebService2.asmx/HelloWorld",
contentType: "application/json:charset=utf-8",
datatype: 'json',
daa:{str:'sadsad'},
beforeSend: function (XMLhttpRequest) {
alert('loading');
},
success: function (data) {
alert($(data).find('string').text());

},
error: function (error) {
alert(error.responseText);
}
});
 

这个是WebService里的代码
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
[System.Web.Script.Services.ScriptService]
public class WebService2 : System.Web.Services.WebService {

public WebService2 () {

//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}

//[WebMethod]
//public string HelloWorld() {
// return "Hellow World";
//就是默认的WebService的代码,然后加了个参数
[WebMethod]
public string HelloWorld(string str)
{
return "Hellow World and"+str;
}

我在WebService里面单独调用是没有问题的,调用那个默认的HelloWorld也是没有问题的。但是是要加了参数,而且就算data:{}不填写他都要报错500"Internal Server Error"
实在搞不定了,请教大神们。
...全文
评论 9
收藏 已收藏
分享
返回顶部
kuawai
Web Services 12,164 成员 16,322 内容