0

Hi all, I am having a problem with this js function. If I make it redirect then the rest of the script does nothing. However if I remove the line: window.location.href = "index.php?page=news&cmd=comments&newsid=" + pageid + "&del=1" then all is fine except then there is no redirecting... so what do I need to be doing here?

function delete_comment(pageid, commentid, type){

        var answer = confirm("Are you sure you want to delete this comment?");

        if(answer == true){

                initialize();

                var infoStr = "cmd=" + encodeURIComponent(escape('delete_comment'));
                infoStr += "&commentid=" + encodeURIComponent(escape(commentid));
                infoStr += "&type=" + encodeURIComponent(escape(type));
                var url = "ajaxrequest.php";

                request.open('POST',url, true);
                request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                request.send(infoStr);
                
                window.location.href = "index.php?page=news&cmd=comments&newsid=" + pageid + "&del=1";
                
                request.onCompletion = function(){

                       window.location.href = "index.php";

                }

        }

}

Thanks for your time.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sridhar_ratna
0

i am also facing the same problem. after a long search n research i noticed that ajax will not redirect from a page but it can only update the content in a page. just put a statement like before window.location.href
alert("succes");

this way solved my problem in IE 6/7/8 and firefox browsers.
If you have any other solution plz share.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.