Follow by Email

Tuesday, October 15, 2013

sending data from jquery to webservice | calling web service from jquery on ajax/json post in

hi in this post i will show how to call a webservice from jquery using ajax/Json post in :

1. add in web.config

      <allow users="*"/>

2. add a webservice file and in codebehind of it add method to be called on ajax-json post request:

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class WebService : System.Web.Services.WebService {

    public WebService () {

    public string HelloWorld(string message, string Type)
        return "Hello World";

3.   Jquery code to be used on the html page to call a webservice on ajax/json post request :

   var Tag = '{message: "' + name.val().toString() + '", Type: "' + 'A' + '"}';

                            $.ajax({ type: "POST", url: "WebService.asmx/HelloWorld", cache: false, contentType: "application/json; charset=utf-8", data: Tag, dataType: "json",
                                success: function (msg) {


                                error: function (response) {




No comments:

Post a Comment