52

以下のコードは、住所を入力して送信ボタンを押すと、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"     />&nbsp;
        <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>&nbsp;
        <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>';

?>
4

5 に答える 5

140

これを行うのに jQuery は必要ありません。JavaScript の力を活用してください。

window.location.reload()
于 2010-05-10T15:00:29.403 に答える
23

その行を次のように置き換えます。

$("#someElement").click(function() {
    window.location.href = window.location.href;
});

また:

$("#someElement").click(function() {
    window.location.reload();
});
于 2010-05-10T15:01:05.913 に答える
6

またはそれ以上

window.location.assign("relative or absolute address");

すべてのブラウザとモバイルで最適に機能する傾向があります

于 2012-06-20T07:40:37.730 に答える
1

次のコードを適用することにより、新しいイベントを追加した後にイベントを更新できます。 -イベントをリリースする -イベント ソースを設定する -イベントを再レンダリングする

  $('#calendar').fullCalendar('removeEvents');
                  $('#calendar').fullCalendar('addEventSource', YoureventSource);         
                  $('#calendar').fullCalendar('rerenderEvents' );

それは問題を解決します

于 2016-01-15T08:59:03.633 に答える
1

と置換する:

$('#something').click(function() {
    location.reload();
});
于 2013-10-10T09:28:47.763 に答える