我有一个asp.net Web服务,我想通过Jquery Ajax调用,但执行我得到500 Internal Server Error
和响应我得到{"Message":"Invalid JSON primitive: Name.","StackTrace":"
看到在浏览器开发工具的输出(萤火虫)。 这里是我的web服务代码..问题通过jQuery的Ajax调用WebService
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class DateWebService : System.Web.Services.WebService {
HttpRequest request;
public DateWebService() {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string GetData(string name, string contact, string email) {
string Name = request[name];
string Contact = request[contact];
string Email = request[email];
return Name+Contact+Email;
}
}
这里是我的jQuery Ajax代码..
$(document).ready(function(){
$("#Button1").click(function() {
$.ajax({
type: "POST",
url: "/ASPNET_WebServices_JQuery/DateWebService.asmx/GetData",
data: { 'Name': 'SRI', 'Contact': '787979879898', 'Email': '[email protected]' },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg)
{
$("#output").text(msg.d);
}
});
});
});
请帮我解决这个issue..Thanks ...
它不工作在所有。 – 2014-11-24 12:12:32
检查已编辑的答案.... – 2014-11-24 12:17:48
'未知的网络方法GetData'错误放在'静态' – 2014-11-24 12:23:06