Note that there are some explanatory texts on larger screens.

plurals
  1. POI'm not sure that my ajax navigation works fine
    text
    copied!<p>I tried to make menu with history api. But it seems to me it works not fine, and I got reasons to think so:</p> <p>1 my "title" not changing</p> <p>2 if I click to fast on my links I got a blink of a page as it is reloaded but it shouldn't!(but if I click slow it is ok. How to prevent reload or blinking?)</p> <p>please tell me waht I do wrong</p> <pre><code> $(document).ready(function(){ sliderStartUp() //menu click $('.navigation').click(function(){ //fill the storage var storage = { url: $(this).children('a').attr('href'), title: $(this).children('a').attr('title') }; history.pushState(null, storage.title, storage.url ); $.ajax({ url: $(this).children('a').prop("href"), cache: false, success: function(data){ //if the data you return is a css notation (eg: #id) of the location of the title name JqObj = $(data); var addSmth = JqObj.find('#central').html(); $("#central").html('').html(addSmth); sliderStartUp() } }); return false; }); function sliderStartUp(){ $('#slider').nivoSlider({ effect: 'fold', animSpeed: '500', pauseTime: '4000' }); } }); </code></pre> <p>here is my havigarion</p> <pre><code> &lt;ul id="navig"&gt; &lt;?php if ($_SERVER['REQUEST_URI'] == "/") { $_SERVER['REQUEST_URI'] = "/index"; } $arrayNav = array( array ( 'name' =&gt; 'yyyyyy', 'title' =&gt; 'yyyyyyyyyyy', 'link' =&gt;'http://bistro.loc/index', 'identificator' =&gt; 'id_index', 'pattern' =&gt; '/index/i' ), array ( 'name' =&gt; 'xxxxxx', 'title' =&gt; 'xxxxxxx', 'link' =&gt; http://bistro.loc/price', 'identificator' =&gt; 'id_price', 'pattern' =&gt; '/price/i' ), array ( 'name' =&gt; 'aaa', 'title' =&gt; '', 'link' =&gt; 'http://bistro.loc/#' , 'identificator' =&gt; 'id_serv', 'pattern' =&gt; '/#/i' ), array ( 'name' =&gt; 'ssss', 'title' =&gt; '', 'link' =&gt; 'http://bistro.loc/#' , 'identificator' =&gt; 'id_cont', 'pattern' =&gt; '/#/i' ), array ( 'name' =&gt; 'dddd', 'title' =&gt; '', 'link' =&gt; 'http://bistro.loc/#' , 'identificator' =&gt; 'id_about', 'pattern' =&gt; '/#/i' )); foreach ($arrayNav as $item) {if (preg_match($item['pattern'],"http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] )) { echo "&lt;li class = \"navigation\" id = \"".$item['identificator']."\" tltle=\"".$item['title']."\"&gt;&lt;a href=\"".$item['link']."\" class=\"active\"&gt;".$item['name']."&lt;/a&gt;&lt;/li&gt;"; }else{ echo "&lt;li class = \"navigation\" id = \"".$item['identificator']."\" tltle=\"".$item['title']."\"&gt;&lt;a href=\"".$item['link']."\"&gt;".$item['name']."&lt;/a&gt;&lt;/li&gt;";} ;} ?&gt; &lt;/ul&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload