일부는 내 문제를 밝힐 수 있기를 바랍니다. 기본적으로 특정 DOM 요소가있는 경우에만 코드 블록을 실행하려고합니다. 만약 그렇다면 나는 약간의 비트와 밥을 수행 한 다음 함수를 호출한다. 그러나 함수가 정의되지 않았기 때문에 함수가 범위에 있지 않음을 알립니다. "getFeed();"IF 범위 내 기능 범위
$(document).ready(function()
{
if ((document.getElementById("view<portlet:namespace/>:editSplash")!= null)) {
console.log("notifications scripted started");
// hide loading box/ notify on body load
$('.ajaxErrorBox').hide();
$('.loadingNotifications').hide();
$('.notifyWindow').hide();
getFeed();
// set up refresh button for reloading feed
$('.refreshFeed').click(function() {
$('.notifyWindow').hide();
$('.notifyWindow').empty();
console.log("notifications clicked");
getFeed();
});
// begin ajax call using jquery ajax object
function getFeed()
{
$('.notifyWindow').empty();
console.log("ajax call for feed starting");
$.ajax ({
type: "GET",
url: "http://cw-pdevprt-05.tm-gnet.com:10040/notificationsweb/feed?username=uid=<%@ taglib uri="/WEB-INF/tld/engine.tld" prefix="wps" %><wps:user attribute="uid"/>",
dataType: "text/xml",
timeout: 10000,
success: parseXml
});
};
// show loading box on start of ajax call
$('.notifyWindow').ajaxStart(function() {
$('.refreshFeed').hide("fast");
$('.notifyWindow').hide();
$('.ajaxErrorBox').hide();
$('.loadingNotifications').show("fast");
});
// hide loading box after ajax call has stopped
$('.notifyWindow').ajaxStop(function() {
$('.loadingNotifications').hide("slow");
$('.refreshFeed').show("fast");
});
$('.notifyWindow').ajaxError(function() {
$('.loadingNotifications').hide("slow");
$('.ajaxErrorBox').show("fast");
$('.refreshFeed').show("fast");
});
// parse the feed/ xml file and append results to notifications div
function parseXml (xml) {
console.log("xml parsing begining");
if (jQuery.browser.msie)
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.loadXML(xml);
xml = xmlDoc;
}
$(xml).find("entry").each(function()
{
var $item = $(this);
var title = $item.find("title").text();
var linkN = $item.find("link").attr("href");
var output = "<a href='" + linkN + "' target='_self'>" + title + "</a><br />";
$(".notifyWindow").append($(output)).show();
});
}
}
else {
console.log("notifications not available");
return false;
}
});
DOM 요소가 난 후 getFeed 기능을 시도하고 전화있는 경우 : 아래 코드는 그러나 그것은 다시 정의되지 않습니다. 누군가가 이것에 대해 밝힐 수 있다면 그것은 크게 감사 할 것입니다.
미리 감사드립니다.
요소의 'id'는'view : editSplash'입니까? 유효한 [이름]이 아닙니다 (http://www.w3.org/TR/html401/types.html#type-name). –
kennytm
그것은 유효한 이름입니다. 포틀릿을 사용하여 작업하고 있으며 jsf에서 DOM 요소를 검색하는 데 필요한 이름 공간입니다. 건배 – jonnyhitek
* 다시 정의되지 않은 *로 무엇을 의미합니까? 'getFeed' 함수가 정의되지 않았습니까? –