使多个ajax按顺序执行

The problem here is since the success function will lead the page to another php page. Then the rest of the ajax code will not be executed anymore. Wondering how to make the rest of the code still can be executed after first success function is finished.

$.ajax({
            context:$this,
            url:"/yyqGS/public/form/get_clicked_index.php",
            type:"POST",
            data:{index:'-1' ,index2:$cid},
            success:function () {


            $this.parent().attr("action","/yyqGS/public/form/reply.php?c_id=" + $cid);
                $this.parent().submit();


                $.ajax({
                    url:"/yyqGS/public/form/get_url.php",
                    type:"GET",
                    success:function (d1) {

                        var $data = d1.split(",");
                        location.href = "/yyqGS/public/form/reply_notification2.php?id="+$data[0]+"&country="+$data[1]+"&tid="+$data[2]+"&cid="+$data[3]+"&rid="+$data[4]+"&cuser="+$data[5];

                    },
                    fail:function () {
                        alert("f");
                    }
                })
            }
        })

Please take a try with Deferred Object https://api.jquery.com/category/deferred-object/