如題:
我試圖在一個web的客戶端,利用Script Manager控件去加載一個普通的WCF Service,代碼如下:
html 代碼
<html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title></title> <script type="text/javascript"> function OnTest() { var ajaxClient = new AjaxTest1.IHelloWorldService(); ajaxClient.DoWork(OnComplete, OnError); } function OnComplete(result) { document.getElementById("txt").value = result.toString(); } function OnError(result) { alert(result.toString()); } </script></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="http://localhost/WCFTest/HelloWorldSVC.svc" /> </Services> </asp:ScriptManager> <input id="txt" type="text" /> <input type="button" onclick="OnTest()" value="Button" /> </div> </form></body></html>
?WCF 代碼
[ServiceContract(Namespace = "AjaxTest1")] public interface IHelloWorldService { [OperationContract] string DoWork(); }
[ServiceBehavior(TransactionIsolationLevel = IsolationLevel.Serializable)] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class HelloWorldService : IHelloWorldService { public string DoWork() { return "Hello World!"; } }
但是總是提示如下錯誤:
Error: 'AjaxTest1' is undefined
哪個大蝦幫幫忙????小弟在此拜謝~~~
- 1 回答
- 0 關(guān)注
- 644 瀏覽
添加回答
舉報
0/150
提交
取消