简体   繁体   中英

Asp.net MVC Redirect to another view from current view page using ajax call

I need to call another view from my current view ,i have tried using ajax call and able to call the action and pass parameter and that view is getting binded with loaded data ,but still it remains in the same page,I am new to ajax so i wish anyone can guide me what I am Doing wrong


 $.ajax({
                                            type: 'GET',
                                            async: false,
                                            url: "@Url.Action("BookingSearchFX", "AddBooking")",
                                            contentType: 'application/json',
                                            data: { id: id },
                                            cache: false,
                                            dataType: "html",
                                            success: function (data) {
                                                SetData(data);
                                            },
                                            error: function (httpRequest, textStatus, errorThrown) {
                                                alert("Error: " + textStatus + " " + errorThrown + " " + httpRequest);
                                            }
                                        });

And I have already used another form submit ,so I will not be able to use form submit and tried location.href = '@Url.Action("AddBooking", "BookingSearchz")?id=' + id

but it is of no use

在您的ajax调用的成功功能中,使用以下代码重新定向到其他视图:

window.location.href = "/controller/action?id=" + id;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM