我想从 XML 文件中获取国家/地区源和目的地,它在 localhost 中完美运行,但在服务器中无法正常工作,如果我在地图上快速移动光标,在服务器中它会显示不同的目的地国家/地区。
在jquerymap.php
我调用 price_by_countries.php 文件mouseover
和mouseclick
事件,我还传递了 2 个变量,price_by_countries.php
在这个文件中我正在加载 XML 文档,我认为每次都加载 XMLfile 可能会导致这个问题。我是编程新手想尽快解决这个问题..谢谢
jquerymap.php 文件代码
jQuery.ajax({ type: "POST",
url: "price_by_countries.php",
data: "s="+source+"&d="+destination,
dataType: 'HTML',
success: function (msg) {
jQuery("#rightinput").html(msg);
}
});
price_by_countries 文件代码
$xml = simplexml_load_file("rd.xml") or die("Error: Cannot create object");
function processXML($node){
foreach($node->children() as $books ){
if($books['source'] == trim(ucfirst($_REQUEST['s'])) &&
$books['destination'] == trim(ucfirst($_REQUEST['d'])))
{
echo "<pre>";
//echo $books ;
echo 'Source Country from XML file = '.$books['source'] . ' ------ Source Country from Textbox = '. trim(ucfirst($_REQUEST['s'])) ;
echo '<hr>';
echo 'Destination Country from XML file = '.$books['destination'] . ' ------ Destination Country from Textbox = '. trim(ucfirst($_REQUEST['d'])) ;
exit();
}
}
}
processXML($xml);