这个脚本不适合我。
我知道问题出在.on('value')
函数中,但我不知道它是什么。
这是我的脚本:
$(document).ready(function(){
//dynamic content switching inside the content section
function writeContent(page){
//setting post to default error message
var post = "Sorry, This page is undergoing maintenance.";
//firebase data reference for the clicked link's content
var dataRef = new Firebase("https://cityartist.firebaseio.com/"+page);
//inserting the available content to the 'post' variable
dataRef.on("value",function(snapshot){
if(snapshot.val() != null){
post = snapshot.val();
alert("post="+post);
}
});
//showing content in the content section and changing the page's title
$("#content").append("<article class='post'><p>"+post+"</p></article>");
$("title").text("CityArtist.org - "+page);
}
//switching pages using the navigation bar
$(".menu_link").click(function(){
writeContent($(this).attr("name"));
});
});