I have a an asp.net Webservice which i want to call by Jquery Ajax but on Executing i am getting 500 Internal Server Error and in the Response i am getting {"Message":"Invalid JSON primitive: Name.","StackTrace":" on seeing the output in Browser Developer tool(Firebug). Here is my Webservice code..

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class DateWebService : System.Web.Services.WebService {

HttpRequest request;

public DateWebService () {

    //Uncomment the following line if using designed components 
    //InitializeComponent(); 
}

[WebMethod]
public string GetDateTime(string name, string contact, string email) {
   // return DateTime.Now.ToString();

    string Name = request[name];
    string Contact = request[contact];
    string Email = request[email];

    return Name+Contact+Email;
}    
}

and here is my jquery Ajax Code..

$(document).ready(function(){

        $("#Button1").click(function() {


            $.ajax({
                type: "POST",
                url: "/ASPNET_WebServices_JQuery/DateWebService.asmx/GetData",
                data: { 'Name': 'SRI', 'Contact': '787979879898', 'Email': 'hr@.com' },
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg)
                {
                    $("#output").text(msg.d);
                }
            });
        });

    });

Please help me to resolve this issue..Thanks...

Related posts

Recent Viewed