在 Dreamweaver 模板上使用 xmlhttp.open 时遇到问题

发布于 2024-12-19 14:17:54 字数 501 浏览 1 评论 0原文

我在 DW 上有一个模板,我网站上不同目录中的数百个页面都依赖该模板。我最近添加了一个注销按钮,单击该按钮即可执行 AJAX 请求。

我有这一行:

xmlhttp.open("GET","../folder1/folder2/something.php?something=something",true);

现在,当我保存模板(更新链接到模板的所有页面)时,该行代码对于每个页面都保持相同,并且因为并非每个页面都与模板位于同一目录中,所以有些页面(大多数)返回 404 错误,因为找不到文件 (something.php)。

通常,在 DW 中,当我在 CSS 中执行类似操作(例如链接背景图像)时,DW 会将 URL 更改为适合其更新的每个页面。但这里的情况并非如此。

我无法进入每个页面并编辑每个页面,也无法快速查找和替换,因为代码位于锁定区域,这意味着我只能在模板上编辑它。

有什么想法或替代方案吗?

谢谢

I have a template on DW that hundreds of pages located in different directories on my site rely on. I've recently added a logout button that does an AJAX request on click.

I have this line:

xmlhttp.open("GET","../folder1/folder2/something.php?something=something",true);

Now when I save the template (update all the pages that are linked to the template), that line of code stays the same for every page, and because not every page is in the same directory as the template, some (most) return a 404 error as the file (something.php) could not be found.

Usually, in DW, when I do something like this in CSS (linking a background image for example), DW changes the URL to the appropriate for each page it updates. But that's not the case here.

I cannot go into every page and edit each one, neither can i do a quick find and replace as the code is in a locked region which means i can only edit it on the template.

Any ideas, or alternatives?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林散布 2024-12-26 14:17:55

Dreamweaver 不会更新 JavaScript 中的路径。

您可以使用文件的根相对路径。由于 ../ 似乎来自您的模板文件,因此我假设您的文件位于您的站点内:

{your site root}/folder1/folder2/something.php

因此,如果您尝试改为:

xmlhttp.open("GET","/folder1/folder2/something.php?something=something",true);

请注意,我删除了 ..,并且路径有一个前导 /。本文可能提供更多信息:http://www.communitymx.com/内容/article.cfm?cid=230ad

Dreamweaver does not update paths in JavaScript.

What you can use is a root relative path to your file. Since it seems that ../ is from your template file, I'll assume that your file is located within your site at:

{your site root}/folder1/folder2/something.php

So if you tried instead:

xmlhttp.open("GET","/folder1/folder2/something.php?something=something",true);

Note that I dropped the .., and the path has a leading /. This article may give a little more info: http://www.communitymx.com/content/article.cfm?cid=230ad

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文