---
title: "How do you invoke a web method of web service in AJAX?"  
description: "How do you invoke a web method of web service in AJAX?"  
author: "Varun Agrawal"  
published: 2011-03-29  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/746/how-do-you-invoke-a-web-method-of-web-service-in-ajax  
category: "ajax"  
tags: ["ajax"]  
reading_time: 1 minute  

---

# How do you invoke a web method of web service in AJAX?

In order to use a webmethod of a webservice, we need to add the reference of webservice in the <services> section of ScriptManager. Under services you have to configure the servicepath. \
\
<asp:ScriptManager ID="ScriptManager1" runat="server"> \
<Services> \
<asp:ServiceReference Path="..\service1.asmx" /> \
</Services> \
</asp:ScriptManager> \
\
Inside JAvascript Use methods of this service directly like \
service1.methodname() \

## Answers

### Answer by Varun Agrawal

In order to use a webmethod of a webservice, we need to add the reference of webservice in the <services> section of ScriptManager. Under services you have to configure the servicepath. \
\
<asp:ScriptManager ID="ScriptManager1" runat="server"> \
<Services> \
<asp:ServiceReference Path="..\service1.asmx" /> \
</Services> \
</asp:ScriptManager> \
\
Inside JAvascript Use methods of this service directly like \
service1.methodname() \


---

Original Source: https://www.mindstick.com/interview/746/how-do-you-invoke-a-web-method-of-web-service-in-ajax

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
