Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting to a page after post from within ajax

I want to redirect to the action Index, controller Admin after the post from ajax.

$.post("/Admin/Create", { inputs: inputs, columnsCount: columnsCount, });

How can I change this code to redirect it to the index page after success?

like image 923
user269431 Avatar asked Dec 07 '22 04:12

user269431


1 Answers

use the 3rd parameter of post

$.post(
    "/Admin/Create", 
    { inputs: inputs, columnsCount: columnsCount, },
    function() {
        window.location.replace("/Admin/index");
    }
);
like image 97
harpax Avatar answered Feb 06 '23 00:02

harpax