我确定我没有正确格式化结果或类似的东西。任何帮助表示赞赏。谢谢,加里
这是 JavaScript 部分:
$.ajax({
type: 'POST',
url: '../ajaxservices.asmx/HelloWorld',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: '{}',
success: function(data){
that.resultsField.innerHTML = data.d;
},
error: function() {
that.resultsField.innerHTML = 'Error';
}
});
这是网络服务部分:
namespace WorkbenchWebServices
{
[System.Web.Script.Services.ScriptService()]
[WebService(Namespace = "http://microsoft.com/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class ajaxservices : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(string name)
{
return "Gary Hello World-";
}