【发布时间】:2012-02-06 17:48:17
【问题描述】:
我就是无法让它工作!每当我单击按钮时,什么都没有发生。已经用 .text('hello world') 替换了 .load 方法,它可以正常工作,所以我的问题似乎出在方法的 url 中。到处寻找答案,但认为我必须忽略一些非常明显的东西,因为没有看到任何地方发布相同的东西。请帮助它让我发疯!!!
客户端:
<script src="Scripts/jQuery-1.7.1.js" type="text/javascript"></script>
<script type="text/javascript">
// Cannot get this to work
$(function () {
$('#buttonSays').click(function () {
$('div').load('AjaxServices.asmx/HelloWorld');
});
});
</script>
</head>
<body>
<h1>Hello World from Web Service</h1>
<button type="button" id="buttonSays">Get Info</button>
<p>The site says...</p>
<div id="divSays1"></div>
<div id="divSays2"></div>
<div id="divSays3"></div>
</body>
服务器端:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class AjaxServices : System.Web.Services.WebService
{
private static int count = 0;
[WebMethod]
public string HelloWorld()
{
count++;
return "Hello World #" + count.ToString();
}
【问题讨论】:
标签: c# jquery web-services load asmx