How to use JQuery to call a WebService (*.asmx) method?
2012-10-10 16:24
507 查看
【http://www.tomot.de/en-us/article/8/asp.net/how-to-use-jquery-to-call-a-webservice-asmx-method】
Introduction
This article will provide a short introduction of using Jquery to call a method from a webservice.Jquery Ajax to a WebService method
1. Add a WebService to your project. Rightclick on your project "Add -> New Item" and add a new Web Service to the project:2. Replace the class definition with this one:
and replace the HTML content with
(That's all you need to do if you are using .net 4.0 (in previous versions you may need to add a ScriptHandler to your web.config) and no IIS 7.5 Urlrewriting module (see the warning at the end of the article)).
The result will be:
Jquery Ajax to a WebService method with parametes from a TextBox
So far we only used static content in the JavaScript file, which is not very useful.Let's add a TextBox to our html:
To add a little more complexity, let's also assume that the yellow button should only perform the Ajax call, if the TextBox is not empty.
JavaScript:
Complete HTML:
Warning
If you are using the UrlRewrite 2 Module for IIS 7.5, you need be careful with the LowerCaseRule. In my case, I spend hours trying to figure out, why my method wasn't called. It turned out to be, that I used PascalCase for the naming of my method, but the method was never called because the UrlRewrite Module changed the casing:相关文章推荐
- How to use Security Policies in WebLogic SCA Web Service Binding
- how to call Web service in Excel 2003 / Excel 2005
- How to use CreateChildContorls method inherited from System.Web.UI.Control
- Use Http Post to call Web Service
- when jquery.ajax() call wcf,if success,how to use wcf return value?
- Use VBA to call Web Service
- How to use HttpWebRequest to post data to another page which is on another server
- REST vs. SOAP: How to choose the best Web service
- How to use AspnetUpload™ in your web application
- Chinese version QQ—how to install it and use it to make a audio call and video call
- How To Use the PivotTable Office Web Component with VB (转载自微软)
- How To Write A Simple PHP/MySQL Web Service for an iOS App(1)
- How to use Atlas in our Web Projects
- How to use Spring @Component, @Repository, @Service and @Controller Annotations?
- Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
- Using UTL_DBWS to Make a Database 11g Callout to a Document Style Web Service
- How To Use the Spreadsheet Web Component with Visual Basic
- How to use HttpWebRequest to send POST request to another web server?
- RESTful WCF Services with No svc file and No config and How to use Service Route
- How To Write A Simple PHP/MySQL Web Service for an iOS App(2)