Click here to Skip to main content
15,306,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a JS function that makes an AJAX Async call.
function PostCall() {
        $('#txtRes').val('Please Wait......');
        var reqval = $('#txtReq').val();
            url: "@urlsMenu",
            type: 'post',
            data: "{'name':'" + reqval + "'}",
            async: true,
            contentType: "application/json",
             success: function (result) {



I have a function in Controller class that makes a Service call.
public JsonResult PostAsync(string name)
            string val = "Not Found ";
            MySr.Service1Client scc = new MySr.Service1Client();
          scc.GetDataCompleted += (result, e) =>
               val = e.Result;
               string str = val;


           return Json(val, JsonRequestBehavior.AllowGet);

But, my problem is, the Server-Side function already returns the value (as "Not Found") instead of the value received after the webservice call.

I want the function to return the value after the webservice returns the value.
Updated 10-May-12 1:13am

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