我想从带有jquery的html调用Web服务函数,但它返回如下错误:
Message":"Invalid web service call, missing value for parameter: \u0027to\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)...
www.xxxxx.com/website/demo.html
上的html网页和www.xxxxx.com/web/xx.asmx
这是我的js:
<script>
function mail() {
var email = 'xxxx';
var nameSurname = 'xxxx';
var phone = 'xxx';
var siteName = 'asdf';
var numberOfApartment = '3';
var mission = 'asdf';
$.ajax({
type: "GET",
url: 'http://www.xxxxx.com/web/xx.asmx/SendMail',
data: JSON.stringify({ to: email, nameSurname: nameSurname, phone: phone, siteName: siteName, numberOfApartment: numberOfApartment, mission: mission }),
dataType: "json",
contentType: "application/json",
success: function (result) {
alert("Successed");
},
error:
function (result) {
alert('error');
}
});
}
</script>
这是我的网络服务功能:
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public string SendMail(string to, string nameSurname, string phone, string siteName, string numberOfApartment, string mission)
{
return "";
}
我的错误在哪里?