Javascript 页面重新加载之前显示的消息,页面重新加载后不工作

Javascript 页面重新加载之前显示的消息,页面重新加载后不工作,javascript,ajax,Javascript,Ajax,我有一个ajax响应代码,如下所示 function click_delete_reply(){ if ((ajMsgDel.readyState == 4) && (ajMsgDel.status == 200)) { var restxt = ajMsgDel.responseText; if (restxt == "success") { location.reload(); displ

我有一个ajax响应代码,如下所示

function click_delete_reply(){
    if ((ajMsgDel.readyState == 4) && (ajMsgDel.status == 200)) {
        var restxt = ajMsgDel.responseText;
        if (restxt == "success") {
            location.reload();
            display_messagesuccess(
                "Message Delete has been successfully performed!");
        }
    }
}

我需要在ajax响应成功后重新加载页面,然后我需要在“div”中编写一条消息。但在这里显示消息之后,它只执行页面加载。我能做些什么来克服这个问题?请帮帮我

你在这里应该做的是

1. Instead of Ajax Call give a server request and do the server side processing. 
a) If the job is done successfully just send the message as the request parameter. Read that message and display where ever you want. 
b) If the job fails then just return the values you need as response back to the page and display them where they should be.

由于每次加载页面时都会加载脚本,因此在重新加载页面后,无法逐个脚本显示消息。您可以显示消息,然后重新加载页面。或者按照我上面提到的方法去做。

好的,好的,然后试试这样的东西

在重新加载之前,将一些参数附加到url。这样,您就可以在服务器端知道这是否是来自ajax的重新加载,并像“重新加载”一样返回一条消息。然后你要这样做:

$(function(){
   //if the param in url is called "reloaded"
   // then show message

});
$(函数(){});与“DOM已就绪”相同


对不起,我在车上,不能写太多。请随便问

重新加载页面后,您无法写入消息,因为重新加载()后,您的js不再运行;那么我该如何解决这个问题呢,伙计@Doniy或者为什么不先显示消息,然后重新加载?这里的顺序没有什么区别,因为您的ajax作业无论如何都是成功的。我需要在作业完成后显示消息,在ajax中的页面重新加载中,我正在更新来自DB的某些值。这就是为什么我需要重新加载后的消息。有什么办法吗@Doniyorth这是做不到的,伙计,因为它在另一个基金会工作!!我怎样才能克服这个问题?有什么想法吗?你可以传递一个参数,比如
?msg=这是消息
。然后在UI上显示此消息