Javascript函数在另一个域中没有被调用

Javascript function not getting called in another domain

本文关键字:调用 函数 另一个 Javascript      更新时间:2023-09-26

不知道为什么下面的函数"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中看到的),并查看两个页面中有什么不同,您可以更好地进行比较。

另外,查看调试控制台中报告了哪些错误(如果有的话)?