下面的代码在你输入地址并点击提交按钮时显示Google地图和搜索结果。我一直在尝试强制页面在点击提交按钮后完全刷新或重新加载,但是我无法正确地使其工作。它会在页面中加载结果,但是我希望页面在加载结果时完全刷新,就像当您在浏览器上点击后退按钮时一样。希望这讲得清楚。我认为答案在下面完整代码的这行代码中,但我不太了解jQuery。
<script type="text/javascript">
(function($) {
$(document).ready(function() {
load();';
以下是完整的代码。非常感谢您的帮助!
<?php
/*
SimpleMap Plugin
display-map.php: Displays the Google Map and search results
*/
$to_display = '';
if ($options['display_search'] == 'show') {
$to_display .= '
<div id="map_search" style="width: '.$options['map_width'].';">
<a name="map_top"></a>
<form onsubmit="searchLocations(\''.$categories.'\'); return false;" name="searchForm" id="searchForm" action="http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'">
<input type="text" id="addressInput" name="addressInput" class="address" />
<select name="radiusSelect" id="radiusSelect">';
$default_radius = $options['default_radius'];
unset($selected_radius);
$selected_radius[$default_radius] = ' selected="selected"';
foreach ($search_radii as $value) {
$r = (int)$value;
$to_display .= '<option valu e="'.$value.'"'.$selected_radius[$r].'>'.$value.' '.$options['units']."</option>\n";
}
$to_display .= '
</select>
<input type="submit" value="'.__('Search', 'SimpleMap').'" id="addressSubmit" class="submit" />
<p>'.__('Please enter an address or search term in the box above.', 'SimpleMap').'</p>
</form>
</div>';
}
if ($options['powered_by'] == 'show') {
$to_display .= '<div id="powered_by_simplemap">'.sprintf(__('Powered by %s SimpleMap', 'SimpleMap'),'<a href="http://simplemap-plugin.com/" target="_blank">').'</a></div>';
}
$to_display .= '
<div id="map" style="width: '.$options['map_width'].'; height: '.$options['map_height'].';"></div>
<div id="results" style="width: '.$options['map_width'].';"></div>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
load();';
if ($options['autoload'] == 'some') {
$to_display .= 'var autoLatLng = new GLatLng(default_lat, default_lng);
searchLocationsNear(autoLatLng, autoLatLng.lat() + ", " + autoLatLng.lng(), "auto", "'.$options['lock_default_location'].'", "'.$categories.'");';
}
else if ($options['autoload'] == 'all') {
$to_display .= 'var autoLatLng = new GLatLng(default_lat, default_lng);
searchLocationsNear(autoLatLng, autoLatLng.lat() + ", " + autoLatLng.lng(), "auto_all", "'.$options['lock_default_location'].'", "'.$categories.'");';
}
$to_display .= '
});
})(jQuery);
</script>';
?>