Click here to Skip to main content
15,889,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I using jquery alert, I have a button in the page, on clic run some code in the controler, then it must apper jquery alert with an ok button. This must reflesh the page, wherever if happens in the first clic or in jquery alert.

please any ideas

What I have tried:

this is my code

JavaScript
$(document).on("click", ".icon-refresh", function (e) {
            $("#loading").show();
            $("#msg").html('');
            $("#myModalLabel").html("alert");
            $("#btnClose").hide();
            var url = $(this).parent().attr("href");
            $("#myModal2").modal("show");
            $.post(
                url,
                function (result) {
                    $("#loading").hide();
                    var msg = result.msj;
                    $("#msg").html(msg);
                    $("#myModalLabel").html("alert");
                    $("#btnCerrar").show();
                }, 'json'
            );
            return false;
        });



the rest code of controler

C#
public ActionResult MyMetod()
   {
           some code
           ......
           .....
           ...

           return Json(new { msj = "success" }, JsonRequestBehavior.AllowGet);
   }
Posted
Updated 6-Dec-17 19:18pm

1 solution

I think this will work for you. location.reload(); to reload the page.
JavaScript
function (result) {
$("#loading").hide();
var msg = result.msj;
$("#msg").html(msg);
$("#myModalLabel").html("alert");
$("#btnCerrar").show();
// check whether the msj is success or not
// show alert here 
alert('<your message>');
// refresh the page
location.reload();
}
 
Share this answer
 
v2
Comments
yetrus 7-Dec-17 9:30am    
I have to use only "jquery alert", and I've tried with location.reload();, so, the page it refresh but the alert does not appears

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