1
我只是无法让它工作!每当我点击按钮什么都没有发生。用.text('hello world')代替了.load方法,它的工作原理好像我的问题出现在方法的url中。已经到处寻找答案,但我认为我必须忽略一些非常明显的事情,因为在任何地方都没有看到过同样的东西。请帮助它让我疯狂!在jQuery中使用Load函数时无法使Web Service 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();
}
哇!非常感谢你!! – user1192900 2012-02-06 18:05:17