找不到使用Ajax的故事板

时间:2017-12-06 01:11:15

标签: javascript jquery ajax

大家好。

var $storyboards; // This is the wrapper were all stroy boards are.
// Listen to URL changes when clicking the back or forward buttons in the browser.
window.onpopstate = function(event) {
  LoadPage(document.location.pathname, !history.state || stateCount > history.state.stateCount);

};

var stateCount = 0;
$( document).ready(function() {	
    $storyboards = $('#storyboards');
    $('.storyboard').attr('data-url', location.pathname);

  
    setTimeout(function(){
      $('body').addClass('splash-screen-hidden');
    }, 3000);
  
   $(document).on('mouseover mouseout','#menu a', function(e){
     
  	 $('#menu a').not(this).toggleClass('toggle');
     
   }).on('click', '#menu a', function(e){ 
     if(e.metaKey || e.ctrlKey) return;
     // Listen to the click event on the a tags in the menu 
     
     // Prevent the default behavior so the browser doesn't load the page.
     e.preventDefault();
     
     var $this = $(this);
     var url = $this.attr('href');
     var title = $this.attr('title');
    
    NavigateToPage(url, title);
      
   })
});

function LoadPage(url, back){
  
  
  var $all_storyboard = $('.storyboard'); // This is all the storyboards we have in the page. 
  
  var $storyboard = $all_storyboard.filter('[data-url="' + url + '"]');
  var storyboard_exists = $storyboard.length > 0;
  
  PreparePageForLoad();
  
  if(storyboard_exists)
    StoryboardIsLoaded($storyboard.hide());
  else {
    console.log("we do not have the storyboard.. go load it!");
    $.ajax({
      url: url,
      success: function(data){
        $storyboard = $('.storyboard', data);
        $storyboard.attr('data-url', url);
        $storyboards.append($storyboard);
        StoryboardIsLoaded($storyboard.hide());
      },
      error: function(){
        alert('Oops! We could not load this page!.');
        GoToRoot();
      }
    })
  }
}

我真的遇到了一个很大的问题,因为我明天早上必须提供我的网站项目,而且现在它的工作效果还不好。

真正的问题是我在我的网页之间加载时遇到了麻烦。我正在使用storyboard和ajax在不加载页面的情况下切换HTML中的代码/内容。所以我在页面之间得到了这些甜蜜的平滑过渡。

我在我自己的服务器和域上测试了它一切正常,但是因为我必须在另一台服务器上交付项目/文件夹,所以它不起作用。主要原因是我必须将它全部放在服务器上的一个文件夹中,这会弄乱根导航。

当我点击链接时,http://websitename.com/html-document/ 但它应该是:http://websitename/myfolder/html-document/

所以问题是它出了我的文件夹并在我的文件夹外寻找HTML文档而不是查看它。

以下是该网站的链接:http://franklyone.com/sylvester-svend/

提前致谢 - 爱

0 个答案:

没有答案