Today I want to implement the use of JavaScript invoke WebService I first thought of ASP.net Ajax because Microsoft's things with convenience, I looked from the Internet, this thing many people have written, I took a demo from the official look at the source code, feel nothing special, So I started to write. Add a webservice.asmx and then join ScriptManager in Default.aspx and set serviecs properties
<asp:scriptmanager runat= "Server" id= "ScriptManager" >
<services>
<asp:servicereference path= "Webservice.asmx"/>
Services>
</asp:ScriptManager>
Then I've added a button and specified the click event for it.
<button onclick= "Gethello ()" >hello world</button>
Next, start writing the script.
<script type= "Text/javascript" >
function Gethello ()
{
WebService. HelloWorld (Callcomplete);
}
function Callcomplete (Result)
{
alert (result);
}
</script>
There should be no problem, but when you click on the button, the wrong foot webservice undefined
I began to compare with others, in the end what is wrong, at first I thought it was a script to write the wrong, and then see webservice that part of the discovery of others as a Microsoft.Web.Script.Services; this namespace, and before the class set the [ ScriptService] Property, I think the problem may be here, plus on it!
Http://www.cnblogs.com/interboy/archive/2006/11/26/573045.html