0

我确定我没有正确格式化结果或类似的东西。任何帮助表示赞赏。谢谢,加里

这是 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-";
        }
4

1 回答 1

0

正如马特所说,“那个”不存在......尝试使用:

$("#result").html(data);
//instead of using
//that.resultsField.innerHTML = data.d; 

<div id="result"></div>
于 2013-10-10T15:55:24.610 回答