Click here to Skip to main content
16,013,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a running WCF Service on my local host and I want to call a simple add method from their but as I do the following search codes it returns null


JavaScript
var baseUrl = "http://localhost:49997/SMD_WCFService/Service.svc?wsdl";

function sendData() {
    var json = '{"result":{"n1":"' + 1 + '"' + ', "n2":"' + 2 + '"}}';

    $.ajax(
    {
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: baseUrl,
        data: json,
        dataType: "json",
        success: function (data) { alert(data) },
        error: function () { alert("not done") }
    });

    // Another Serched Method
    var service = new Service.SMDService();
    var result = service.Add(1, 2);
    alert(result);
}
Posted

1 solution

 
Share this answer
 
Comments
Ammar4556257 12-Dec-12 5:24am    
I have done all on service side good. Also I tried to access the method in C# code that is also fine. But I have to call the methods from JavaScript. Is there any smooth way?
Ammar4556257 18-Dec-12 9:04am    
Thanks Rohit
I ignored these pages during RnD but they worked out when I read them carefully.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900