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.