这是一个万岁的机会,但我很感激任何能为我指明正确方向的想法。
我为我的wordpress网站创建了一个“插件”。我有一个位于服务器上的实时站点和一个安装在Xampp本地的站点。这个插件在live server站点上运行得很好,但当我将其克隆到本地托管站点时,它就不起作用了。
我真的需要这个在当地工作,因为很多原因,我可能会让你厌烦解释。
更多详细信息:当我在本地站点上打开Chrome控制台时,出现一个错误,说明:
Failed to load resource: the server responded with a status of 404(Not Found)
http://localhost:8080/rol/Desktop/sitefolder/htdocs/wordpress/wp-content/plugins/wpnotebook/ajax.php?_=1427163308124&action=1tabs
我的想法是,编码中有一个错误,使其从我的计算机上的物理文件夹中提取,而不是尝试从以下文件夹中提取:
http://localhost:8080/wordpress/wp-content/plugins/wpnotebook/ajax.php?_=1427163308124&action=1tabs
如果是这样的话,我只是不知道该怎么解决。以下是ajax选项卡脚本的代码:
jQuery(document).ready(function($) {
/*$(document).ready(function(){*/
/* This code is executed after the DOM has been completely loaded */
var dirurll = jQuery(\'#dirurl\').val();
var bkid = jQuery(\'#idbook\').val();
//alert(dirurll);
jQuery.ajax({
type: "GET",
url: "/"+dirurll+"/ajax.php",
data: "action="+bkid+"tabs",
cache: false,
dataType: "json",
success: function(Tabs){
jQuery.each(Tabs, function(i){
/* Sequentially creating the tabs and assigning a color from the array: */
var tab = jQuery(\'<li id="Tab-\'+Tabs[i].tab_id+\'" class="tabItem">\'+
\'<div class="tabTitle">\'+
\'<a href="#" class="tab"><span class="left"></span><div class="tabName">\'+Tabs[i].name+\'</div><span class="right"></span></a>\'+
\'</div>\'+
\'<div class="tabCreated">\'+Tabs[i].date_created+\'</div>\'+
\'</li>\');
/* Adding the tab to the UL container: */
jQuery(\'#tabRow\').append(tab);
});
jQuery(\'#tabRow\').sortable({
update : function(event, ui){ // The function is called after the tabs are rearranged
// The toArray method returns an array with the ids of the tabs
var arr = jQuery("#tabRow").sortable(\'toArray\');
// Striping the Tab- prefix of the ids:
arr = jQuery.map(arr,function(val,key){
return val.replace(\'Tab-\',\'\');
});
// Saving with AJAX
jQuery.get(\'/\'+dirurll+\'/ajax.php\',{action:\'rearrangeTabs\',positions:arr,rand:Math.random()});
}
});
/* Caching the tabs into a variable for better performance: */
var the_tabs = $(\'.tab\');
the_tabs.live(\'click\',function(e){
/* If it is currently active, return false and exit: */
if($(this).is(\'.activeTab\')) return false;
jQuery(\'#contentHolder\').empty();
/* "this" points to the clicked tab hyperlink: */
currentTabID = $(this).closest(\'.tabItem\').attr(\'id\').replace(\'Tab-\',\'\');
/* Set the current tab: */
jQuery(\'a.tab\').removeClass(\'activeTab\');
jQuery(this).addClass(\'activeTab\');
jQuery(\'#pageList\').empty();
jQuery.getJSON(\'/\'+dirurll+\'/ajax.php\',{"action":bkid+"pages","tab_id":currentTabID,rand:Math.random()},function(Pages){
jQuery.each(Pages, function(i){
/* Sequentially creating the pages and assigning a color from the array: */
var pageItem = jQuery(\'<li id="Page-\'+Pages[i].page_id+\'" class="pageItem">\'+
\'<div class="pageTitle">\'+
\'<a href="" id="Page-\'+Pages[i].page_id+\'" class="notepage">\'+
\'<span class="left"></span><span class="pageName">\'+Pages[i].name+
\'</span><span class="right"></span></a>\'+
\'</div>\'+
\'<div class="pageCreated">\'+Pages[i].date_created+\'</div>\'+
\'<div class="columns">\'+Pages[i].columns+\'</div>\'+
\'</li>\');
/* Setting the page data for each hyperlink: */
pageItem.find(\'a\').data(\'page\',\'/\'+dirurll+\'/ajax.php\'+\'?action=\'+bkid+\'lists&page_id=\'+Pages[i].page_id);
makeTabsDroppable();
/* Adding the tab to the UL container: */
jQuery(\'#pageList\').append(pageItem).fadeIn(\'fast\');
}); // close $.each(Pages)
// add link to create a new page
var newPage = jQuery(
\'<li id="newPageItem">\'+
\'<abbr title="\'+_(\'New Page\')+\'"><a href="" class="notebookIcons newPage">\'+
\'</a></abbr>\'+
\'</li>\');
jQuery(\'#pageList\').append(newPage);
makePagesDroppable();
// Make the first page the active page
clickPage(); // function located in notebook.php
jQuery(\'#pageList\').sortable({
items : \'li.pageItem\',
update : function(event, ui){ // The function is called after the tabs are rearranged
// The toArray method returns an array with the ids of the tabs
var arr = jQuery("#pageList").sortable(\'toArray\');
// Striping the Tab- prefix of the ids:
arr = jQuery.map(arr,function(val,key){
return val.replace(\'Page-\',\'\');
});
// Saving with AJAX
jQuery.get(\'/\'+dirurll+\'/ajax.php\',{action:\'rearrangePages\',positions:arr,rand:Math.random()});
}
});
}); // close $.get("ajax.php")
e.preventDefault();
})
jQuery(\'a.notepage\').live(\'click\',function(e){
/* "this" points to the clicked page hyperlink: */
var element = $(this);
/* If it is currently active, return false and exit: */
if($(this).is(\'.activePage\')) return false;
/* Set the current page: */
jQuery(\'a.notepage\').removeClass(\'activePage\');
jQuery(this).addClass(\'activePage\');
/* Checking whether the AJAX fetched page has been cached: */
if(!element.data(\'cache\'))
{
/* If no cache is present, show the gif preloader and run an AJAX request: */
jQuery(\'#contentHolder\').html(\'<img src="theme/default/images/ajax_preloader.gif" width="64" height="64" class="preloader" />\');
jQuery.get(element.data(\'page\'),{\'rand\':Math.random()},function(msg){
jQuery(\'#contentHolder\').html(msg);
});
}
}) //close .notepage live click
/* Emulating a click on the first tab so page list is not empty: */
clickTab(); // function located in notebook.php
// Listen for click on New Tab icon
jQuery(\'.newTab\').live(\'click\',function(e){
addTab(\'newTab\',0);
}); // close #newTab click
// Listen for click on Add Page icon
jQuery(\'.newPage\').live(\'click\',function(e){
addPage(\'newPage\', currentTabID);
e.preventDefault();
}); // close #newTab click
} // closing ajax success:
}); // close ajax
});
function addTab(action, id) {
var dirurlll = jQuery(\'#dirurl\').val();
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
var curr_hour = d.getHours();
var curr_min = d.getMinutes();
currentDate = curr_year + "-" + curr_month + "-" + curr_date + " " + curr_hour + ":" + curr_min ;
jQuery.getJSON(\'/\'+dirurlll+\'/ajax.php\',{\'action\':action,\'id\':id,rand:Math.random()},function(Tabs){
jQuery.each(Tabs, function(i){
var tabCreated = Tabs[i].date_created;
tabCreated = tabCreated.substring(0,tabCreated.length-3); // remove the seconds section from the date
/* Build the new tab and append it to the tabRow */
var tab = jQuery(
\'<li id="Tab-\'+Tabs[i].tab_id+\'" class="tabItem">\'+
\'<div class="tabTitle">\'+
\'<a href="#" class="tab"><span class="left"></span><div class="tabName">\'+Tabs[i].name+\'</div><span class="right"></span></a>\'+
\'</div>\'+
\'<div class="tabCreated">\'+tabCreated+\'</div>\'+
\'</li>\');
/* Adding the tab to the UL container: */
jQuery(\'#tabRow\').append(tab);
}); // close .each loop
makeTabsDroppable();
}); // close newTab ajax call
}
function addPage(action,id) {
var dirurlll = jQuery(\'#dirurl\').val();
var bkid = jQuery(\'#idbook\').val();
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
var curr_hour = d.getHours();
var curr_min = d.getMinutes();
currentDate = curr_year + "-" + curr_month + "-" + curr_date + " " + curr_hour + ":" + curr_min ;
jQuery.getJSON(\'/\'+dirurlll+\'/ajax.php\',{\'action\':action,\'id\':id,rand:Math.random()},function(Pages){
jQuery.each(Pages, function(i){
var pageCreated = Pages[i].date_created;
pageCreated = pageCreated.substring(0,pageCreated.length-3); // remove the seconds section from the date
/* Sequentially creating the pages and assigning a color from the array: */
var pageItem = jQuery(\'<li id="Page-\'+Pages[i].page_id+\'" class="pageItem">\'+
\'<div class="pageTitle">\'+
\'<a href="" id="Page-\'+Pages[i].page_id+\'" class="notepage">\'+
\'<span class="left"></span><span class="pageName">\'+Pages[i].name+
\'</span><span class="right"></span></a>\'+
\'</div>\'+
\'<div class="pageCreated">\'+pageCreated+\'</div>\'+
\'<div class="columns">\'+Pages[i].columns+\'</div>\'+
\'</li>\');
/* Setting the page data for each hyperlink: */
pageItem.find(\'a\').data(\'page\',\'/\'+dirurlll+\'/ajax.php?action=\'+bkid+\'lists&page_id=\'+Pages[i].page_id);
// remove the new page and settings links so they can be added back to the end
jQuery(\'#newPageItem\').remove();
/* Adding the tab to the UL container: */
jQuery(\'#pageList\').append(pageItem).fadeIn(\'fast\');
// add link to create a new page
var newPage = jQuery(
\'<li id="newPageItem">\'+
\'<abbr title="\'+_(\'New Page\')+\'"><a href="" class="notebookIcons newPage">\'+
\'</a></abbr>\'+
\'</li>\');
jQuery(\'#pageList\').append(newPage);
jQuery(\'#pageList\').append(newPage).fadeIn(\'fast\');
}); // close $.each(Pages)
makePagesDroppable();
}); // close newTab ajax call
}