简体   繁体   English

(ZEND)路由至JavaScript中的index.phtml

[英](ZEND) Route to index.phtml in javascript

I'm making a button that refreshes a specific div, the div is located in the index.phtml. 我正在制作一个刷新特定div的按钮,该div位于index.phtml中。

 $('#jumbotron-table').load(document.URL);

Is not working, nothing happens. 不起作用,什么也没发生。

Firstly, it would help if you specify exactly what "not working" means. 首先,如果您确切指定“不起作用”的含义,将会有所帮助。 Does anything happen on-screen?, is there an error message in the Javascript console?, if you enter the fuction in immediate mode into the debugger does it work then?, what if you use a fixed URL rather than a variable? 屏幕上是否发生任何事情?Javascript控制台中是否有错误消息?如果您在调试器中以即时模式输入功能,它是否可以正常工作?如果使用固定URL而不是变量怎么办?

document.URL is the URL of the currently loaded page, so you're loading a copy of the current page into a div within that page. document.URL是当前加载页面的URL,因此您要将当前页面的副本加载到该页面内的div中。 Sounds a bit odd but I can't say that it sounds impossible. 听起来有些奇怪,但我不能说这听起来不可能。

Try something like this- 尝试这样的事情-

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.0.min.js"></script>

<html>
    <table id="myTable"><tr><td>Content</td></tr></table>
</html>

<script>
var contentURL= "Stackoverflow_01.html";

$().ready(function() {
  $('#myTable tr td').load(contentURL);
});

</script>

This loads the content of the target file into a table cell in the starting file. 这会将目标文件的内容加载到起始文件中的表单元格中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM