Javascript Jquery在通过Ajax调用另一个页面期间未运行
我有一个索引页面,从我称之为Jquery和PHP页面的索引页面(合并在一个.PHP文件中),如果我单独运行一个.PHP文件,一切都正常运行,但如果我通过Ajax调用同一个页面,那么它就不运行了 示例代码: index.phpJavascript Jquery在通过Ajax调用另一个页面期间未运行,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我有一个索引页面,从我称之为Jquery和PHP页面的索引页面(合并在一个.PHP文件中),如果我单独运行一个.PHP文件,一切都正常运行,但如果我通过Ajax调用同一个页面,那么它就不运行了 示例代码: index.php <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>mouseover demo<
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>mouseover demo</title>
<script src="script/javaScript.js"></script>
</head>
<body>
<a style="cursor:pointer;" onclick="addpage()">click</a>
<div id="view"></div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>mouseover demo</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="script/javaScript.js"></script>
</head>
<body>
<table>
<tr>
<td>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="nstaroverout">
<span>move cursor to change text</span>
</div>
</td>
</tr>
</table>
</body>
</html>
one.php
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>mouseover demo</title>
<script src="script/javaScript.js"></script>
</head>
<body>
<a style="cursor:pointer;" onclick="addpage()">click</a>
<div id="view"></div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>mouseover demo</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="script/javaScript.js"></script>
</head>
<body>
<table>
<tr>
<td>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="nstaroverout">
<span>move cursor to change text</span>
</div>
</td>
</tr>
</table>
</body>
</html>
鼠标悬停演示
移动光标以更改文本
移动光标以更改文本
移动光标以更改文本
如果您尝试删除one.php中的那些jquery.js怎么样
因为当您再次将jquery包含在页面“one.php”中时,它已经包含在页面中一次了,所以我再次被包含,这会导致jquery冲突
index.php
中:
one.php
文件中删除额外的元素(html
,head
,script
):
<table>
<tr>
<td>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="nstaroverout">
<span>move cursor to change text</span>
</div>
</td>
</tr>
</table>
移动光标以更改文本
移动光标以更改文本
移动光标以更改文本
你为什么不让事情变得更简单,在哪里使用
one.php
?我看到change text mouseover.php
这里有两件事需要纠正。1.为什么不使用jquery$.ajax()
,它比用于ajax调用的原始Javascript代码简单易用。2.您的php页面根本不包含任何php代码,据我所知,除非您不echo
php页面中的数据,否则调用页面不会返回任何内容。
<table>
<tr>
<td>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="staroverout">
<span>move cursor to change text</span>
</div>
<br>
<div class="nstaroverout">
<span>move cursor to change text</span>
</div>
</td>
</tr>
</table>