Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi How to call two actionresult method in one ajax call..?
In
$('#st-btn')
button click i'm calling "show1" ActionResult Method
Meanwhile i want to call one more Actionresult method (i.e) show2 in the same call..
In my second ActionResult i want to check whether checkbutton is checked are not?
If checked i want to update the bool value in my success..
Any suggestion would be helpful?

What I have tried:

<pre> $('#st-btn').on('click', function (e) {
                    e.preventDefault();
                    var _data = {
                        VModel: (@Html.Raw(Json.Encode(Model))),
                        IValue: $("#txt1").val(),
                        N: 'justin'

                    }
                    $.ajax({
                        type: 'POST',
                        dataType: "json",
                        contentType: 'application/json; charset=utf-8',
                        url: "@Url.Action("show1")",
                        async: false,
                        data: JSON.stringify(_data),
                        success: function (data) {}
Posted
Updated 26-Mar-17 17:57pm
Comments
Karthik_Mahalingam 26-Mar-17 0:46am    
call like the show1 ajax call
what is the issue
Salt Pepper 26-Mar-17 4:25am    
I want to call show2 if show1 call is success. Is it possible?
SrikantSahu 26-Mar-17 5:12am    
Yes, you can call another Ajax call for show2 in show1's success method

1 solution

Quote:
I want to call show2 if show1 call is success. Is it possible?

Yes possible,
just call the ajax function on the success call back of first method.

     success: function (data) {
             $.ajax({ type: 'POST',
                                    dataType: "json",
                                    contentType: 'application/json; charset=utf-8',
                                    url: "@Url.Action("your action")",
                                    async: false,
                                    data: JSON.stringify(_data),
                                    success: function (data) {}

}
 
Share this answer
 
v2

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