苦恼啊。这是什么原因呀????????????????????????????????????????????
哪个大哥给我看看。
我是用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>
哪个大哥给我看看。
我是用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>
解决方案 »
- 请教IE中嵌入Winform的问题
- [2008/07/15]code
- 使用ajaxpro.dll过一会儿会提示脚本错误
- 询问一些老师,我新手以前就学过ASP现在想学ASP.NET从那里开始有什么书推荐吗?
- 如何实现在点击一个button后弹出一个新页面
- 格式化字符串的问题
- 问大家一个关于Microsoft Visual Studio .NET 2003自带的那个asp.net入门教程的问题,谢谢,比较急!!
- 已经有N个群里面没有人回答了,
- ASP.net中怎样其提高安全性?
- 刚下载了软件流程分析的例子,Rose图,可是没有相关的运用软件,看不了,那有下载的,谢谢了!
- 退出时候的弹窗提示
- C#考试系统考试申请后如何按顺序自动生成考号?
dataType: 'text',
[System.Web.Script.Services.ScriptService]差一个这吧 你和我做的是一样的例子 哈哈