Javascript函数在另一个域中没有被调用
Javascript function not getting called in another domain
不知道为什么下面的函数"test"在这里没有被调用。我正试图从前3个小时调试这个。请提出建议。下面是我的html代码:
下面的代码在一个域中工作正常,但是当我将文件转移到另一个域中时,测试函数没有被调用。
<html>
<head><title>The Website Is Under Construction</title>
<link rel="stylesheet" type="text/css" href="main.css">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
function defaultcity()
{
$("#list").load("pune.php");
$.ajaxSetup({ cache: false });
}
function display_details(shopname,img,shopcode)
{
$( "#reviews" ).empty();
document.getElementById("reviews").style.display='none';
document.getElementById("menu").style.display='block';
var a = document.getElementById("1");
a.onclick = function(){
document.getElementById("reviews").style.display='none';
document.getElementById("photo_gallery").style.display='none';
document.getElementById("menu_card").style.display='none';
return false;
};
var c = document.getElementById("3");
c.onclick = function(){
alert("This is the onclick of Reviews button..after that I am going to call a javascript function test() which is successfully getting called here but not in HOSTING24..pls click on OK and see");
test();
document.getElementById("photo_gallery").style.display='none';
document.getElementById("menu_card").style.display='none';
document.getElementById("reviews").style.display='block';
return false;
};
$("#reviews").load("loadn.php? shopcode="+encodeURIComponent(shopcode)+"&shopname="+encodeURIComponent(shopname)+"&img="+e ncodeURIComponent(img));
return false;
}
</script>
</head>
<body bgcolor=#3B0B0B topmargin="5" bottommargin="0" leftmargin="80" rightmargin="80" onLoad="defaultcity()" >
<script>
function test(){
alert("This function is not getting called on HOSTING24");
}
</script>
<div id="header" valign=top style="background-color:#0B0B61" align="right">
<font color=white>City
<select name="city" id="city" onchange="selectarea()">
<option value="">Select...</option>
<?php
include './connection.php';
$query1 = "select * from cities";
$result1 = mysql_query($query1);
while($row1 = mysql_fetch_assoc($result1))
{
echo '<option value="' . $row1['name'] . '">';
echo $row1['name'];
echo '</option>';
}
echo '</select>';
?>
Area
<div id="areas" name="areas" style="display: inline-block;" >
<select>
<option>select
</option>
</select>
</div>
</font>
<font color=white>My Settings | Password Management | Help | Logout</font></div>
<div align="center">
</div>
</div>
<button onclick="display_details('abd','abc 9.jpg','10')" type="button" >Click me </button>
<br>
<br>
<br>
<table class="ex1" border="1" width="100%" align=center height="330px" class="fixed">
<col width="77px" />
<col width="23px" />
<tr valign=top>
<td width="77%" id="table1">
<table border="1" width="100%" id="table_title">
<tr>
<td>
</td>
</tr>
</table>
<div id="menu" align="center" align="middle">
<ul>
<li><a id="1" href="#" >Home</a></li>
<li><a id="3" href="#" >Reviews</a></li>
</ul>
</div>
<div id="reviews" ></div>
</td>
<td width="23%">
<div><img id="elem1" width="250px" height="250px"></div>
<div id="desc" style="color:white" ></div>
</tr>
</table>
<div id="footer" align="center" style="background-color:#0B0B61">
Copyright © 2014 XYZ Consultancy Services | About XYZ |
Terms of Use | Sitemap | Feedback Form | Browser and Display Compatibility
</div>
</body>
</html>
这行代码中:
$("#reviews").load("loadn.php? shopcode="+encodeURIComponent(shopcode)+"&shopname="+encodeURIComponent(shopname)+"&img="+e ncodeURIComponent(img));
中有空格e ncodeURIComponent(img)
产生错误。我也不知道你为什么要在你的URL空格。
除此之外,我怀疑PHP中的某些内容可能在不同的服务器之间有所不同。如果您查看从两个服务器生成的HTML页面(浏览器在View/Source中看到的),并查看两个页面中有什么不同,您可以更好地进行比较。
另外,查看调试控制台中报告了哪些错误(如果有的话)?
相关文章:
- 如何从模块链中调用函数.导出到节点中
- 调用函数内部的函数
- 在javascript中调用c函数
- DropDownListFor赢得't在更改时调用函数
- Javascript页面调用函数
- 在动画结束之前调用函数
- 允许父窗口在其不同域的子iframe上调用函数
- 运行Infinite Scroll后调用函数时出现问题
- JavaScript:在调用函数的文本输入上按enter键
- 使用大括号和不使用bracs调用函数的区别
- javascript在事件上调用函数
- 从index.html调用函数,该函数无限循环
- 从带参数的字符串变量调用函数中的函数
- 为什么 JS 不在滚动时调用函数
- 是否可以在不更改上下文的情况下调用函数.apply
- 如何在ES6类中使用参数调用函数
- AngularJS:调用函数时编号不更新
- JavaScript中的立即调用函数表达式(IIFE)-传递jQuery
- 在JavaScript中调用函数时自定义此选项
- 调用函数中声明的变量