苦恼啊。这是什么原因呀????????????????????????????????????????????
哪个大哥给我看看。
我是用vs2005直接兴建的asp.net Web项目。然后又添加了个webService.
我在Default.aspx里加了下面的代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server">
    <title>无标题页</title>
<script src="jquery-1.3.1.js"  type="text/javascript"></script>
    
 <style type="text/css">
 .hover   {   cursor: pointer; /*小手*/   background: #ffc; /*背景*/   }
.button   {   width: 150px;   float: left;   text-align: center;   margin: 10px;   padding: 10px;   border: 1px solid #888;   }
 #dictionary   {   text-align: center;   font-size: 18px;   clear: both;   border-top: 3px solid #888;   }
 #loading   {   border: 1px #000 solid;   background-color: #eee;   padding: 20px;   margin: 100px 0 0 200px;   position: absolute;   display: none;   }
 
 </style>  
<script type="text/javascript">
//无参数调用
    $(document).ready(function() {
      $('#btn1').click(function() {
        $.ajax({
          type: "POST",  //访问WebService使用Post方式请求
          contentType: "application/json", //WebService 会返回Json类型
          url: "WebService.asmx/HelloWorld", //调用WebService的地址和方法名称组合 ---- WsURL/方法名
          data: "{}",     //这里是要传递的参数,格式为 data: "{paraName:paraValue}",下面将会看到   
          dataType: 'json',
          success: function(result) {   //回调函数,result,返回值
            $('#dictionary').append(result.d);
          }
        });
      });
    });
//有参数调用   
//$(document).ready(function() {   
//$("#btn2").click(function() {   
//$.ajax({   type: "POST",   
//contentType: "application/json",   
//url: "http://localhost/TestAuto/WebService.asmx/HelloWorld",   
//data: "{value1:'心想事成'}",   
//dataType: 'json',   
//success: function(result) {   
//$('#dictionary').append(result.d);   
//}   });   });   });     //Ajax 为用户提供反馈,利用ajaxStart和ajaxStop 方法,演示ajax跟踪相关事件的回调,他们两个方法可以添加给jQuery对象在Ajax前后回调   //但对与Ajax的监控,本身是全局性的   
$(document).ready(function() {   
$('#loading').ajaxStart(function() {   
$(this).show();   
}).ajaxStop(function() {   
$(this).hide();   
});   
});    
   
   
   
   
 $(document).ready(function() { 
   $('div.button').hover(function() {  
    $(this).addClass('hover');  
     }, function() {  
      $(this).removeClass('hover');   });   });   
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="switcher">   
    <h2>   jQuery 的WebServices 调用</h2>  
     <div class="button" id="btn1">   HelloWorld</div>   
     <div class="button" id="btn2">   传入参数</div>   
     <div class="button" id="btn3">   返回集合</div>   
     <div class="button" id="btn4">   返回复合类型</div>   
     <div class="button" id="btn5">   返回DataSet(XML)</div>   
     </div>   
     <div id="loading">   服务器处理中,请稍后。   </div>   
     <div id="dictionary">   
     </div>   
    </form>
</body>                                                                                                                                                                                                                                                                                                                                 app_Code下的WebService.cs的是默认方法                                                                                                                                                                                                                                                                                                                                                              /// <summary>
/// WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {    public WebService () {        //如果使用设计的组件,请取消注释以下行 
        //InitializeComponent(); 
    }    [WebMethod]
    public string HelloWorld() { 
        return "Hello World" ;
    }
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
</html>

解决方案 »

  1.   

     data: null,     //这里是要传递的参数,格式为 data: "{paraName:paraValue}",下面将会看到   
              dataType: 'text',
      

  2.   

    //若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 
    [System.Web.Script.Services.ScriptService]差一个这吧  你和我做的是一样的例子 哈哈
      

  3.   

    我擦。是楼上的问题。我还故意没建ajax的网站。没想到还是要那个特性的