在 Javascript 中提醒用户更新已成功
我正在尝试使用以下 JavaScript 代码在表单更新时提醒用户。
基本上发生的情况是用户单击潜在客户列表,然后单击编辑,然后将所有客户详细信息加载到编辑器表单中。一旦他们完成编辑用户,他们单击更新按钮,内容将发布到 php 处理脚本,该脚本中还包含各种其他 php 函数,这些函数在用户被发送回潜在客户编辑器之前执行其他命令。详细信息将再次重新加载到表单中,并应用所有编辑,这一切都在一两秒内完成。
更新成功后,它会在 GET 数组中添加一个名为 update=1 的令牌,该令牌会在 url 中传递回编辑器。
我想做的是当客户记录已通过 JavaScript 中的警报框成功更新时提醒用户。
我正在使用以下代码,但不确定如何让 javascript 在 url 中查找 update=1,并且仅在客户端已更新时显示更新成功,而不是在客户端加载时在初始加载时显示客户名单。
JAVASCRIPT
<script language="JavaScript">
function prospectupdated ()
{alert("Prospect Updated !")
}
</script>
HTML
<body onLoad="prospectupdated()">
就目前而言,每次页面加载时都会加载,无论 url 中的 update=1 标记是否存在,是否有人知道有关如何执行此操作的任何教程,或者知道它自己是如何执行此操作的不介意分享吗? :-) 谢谢
I am trying to use the following javascript code to alert the user when a form has been updated.
Basically what happens is a user clicks on a list of prospective clients, they click edit, this then loads all the clients details into an editor form. Once they have finished editing the user they click the update button and the contents are posted to a php processing script, which also has various other php functions in it that perform other commands before the user is then sent back to the prospect editor where the user details are re loaded into the form again with all the edits applied, this is all done in a second or two.
Once the update has been successful it adds a token into the GET array called update=1 which is passed in the url back to the editor.
What I am trying to do is alert the user when the clients record has been successfully updated by way of an alert box in javascript.
I am using the following code but am no sure how to get the javascript to look for the update=1 in the url and only display update successful when the client has been updated, and not on the initial load when the client is getting loaded from the list of clients.
JAVASCRIPT
<script language="JavaScript">
function prospectupdated ()
{alert("Prospect Updated !")
}
</script>
HTML
<body onLoad="prospectupdated()">
As it stands at the moment it loads every time the page loads, whether the update=1 token in the url is there or not, does anyone know of any tutorials on how to do this, or knows how it do it themselves and doesn't mind sharing ? :-)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要测试更新:
You need to test the update:
看这里:如何从 javascript 检索 GET 参数?
它将显示您如何获取 update=1 的值。
然后您将有一个 if() 语句来检查 update=1 是否。如果是,则执行alert()。
Look here: How to retrieve GET parameters from javascript?
It will show you how to obtain the value for the update=1.
You would then have an if() statement to check if update=1. If it does, then execute the alert().