Click here to Skip to main content
14,694,553 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();
        $.ajax({
            url: "@urlsMenu",
            type: 'post',
            data: "{'name':'" + reqval + "'}",
            async: true,
            contentType: "application/json",
             success: function (result) {
                debugger;
                $('#txtRes').val(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;

           };
           scc.GetDataAsync(name);

           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.
Posted
Updated 10-May-12 2:13am
v3

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