latheesan
02-15-2009, 07:16 PM
Hi,
I am working on a website that makes use of Xilinus Portal (http://blog.xilinus.com/2007/8/26/prototype-portal-class).
The problem is, I can't use prototype ajax to load contents dynamically into every widget i create. The response text from the ajax load event always says "undefined". There is no javascript error either.
This is what I have so far.
JS Function To Make AJAX Requests
function Ajax_Load (file)
{
var uid = new Date();
new Ajax.Request(file +'.php?uid='+ uid.getTime(),
{
method: 'get',
onSuccess: function(transport){
var response = transport.responseText || "No response from server ...";
return response;
},
onFailure: function(){ alert(file +'.php" does not exists on this server!'); }
});
}
Create Portal and Add Widgets
var portal;
function onOverWidget(portal, widget)
{
widget.getElement().insertBefore($('control_buttons'), widget.getElement().firstChild);
$('control_buttons').show();
}
function onOutWidget(portal, widget)
{
$('control_buttons').hide();
}
function removeWidget(element)
{
var widget = $(element).up(".widget").widget;
if (confirm('Are sure to remove this widget?'))
{
document.body.appendChild($('control_buttons').hide())
portal.remove(widget);
}
}
function onChange() { }
function init()
{
// Create New Portal
portal = new Xilinus.Portal("#main div", {onOverWidget: onOverWidget, onOutWidget: onOutWidget, onChange: onChange});
// Load Contents
var widget_1 = Ajax_Load('widget_1');
// Load Default Widgets
portal.add(new Xilinus.Widget().setTitle("News Widget #1").setContent(widget_1), 0);
// Add controls buttons
portal.addWidgetControls("control_buttons");
}
Event.observe(window, "load", init);
widget_1.php
<?php echo "Hello World!"; ?>
When the site loads, i see the widgets and they are working fine (as in they are dragable and each widget can be closed etc). The problem is, the contents from the .php file is not being loaded via ajax and put into the widget.
Where I am I going wrong? Can someone shed some light on this please. Thank you.
I am working on a website that makes use of Xilinus Portal (http://blog.xilinus.com/2007/8/26/prototype-portal-class).
The problem is, I can't use prototype ajax to load contents dynamically into every widget i create. The response text from the ajax load event always says "undefined". There is no javascript error either.
This is what I have so far.
JS Function To Make AJAX Requests
function Ajax_Load (file)
{
var uid = new Date();
new Ajax.Request(file +'.php?uid='+ uid.getTime(),
{
method: 'get',
onSuccess: function(transport){
var response = transport.responseText || "No response from server ...";
return response;
},
onFailure: function(){ alert(file +'.php" does not exists on this server!'); }
});
}
Create Portal and Add Widgets
var portal;
function onOverWidget(portal, widget)
{
widget.getElement().insertBefore($('control_buttons'), widget.getElement().firstChild);
$('control_buttons').show();
}
function onOutWidget(portal, widget)
{
$('control_buttons').hide();
}
function removeWidget(element)
{
var widget = $(element).up(".widget").widget;
if (confirm('Are sure to remove this widget?'))
{
document.body.appendChild($('control_buttons').hide())
portal.remove(widget);
}
}
function onChange() { }
function init()
{
// Create New Portal
portal = new Xilinus.Portal("#main div", {onOverWidget: onOverWidget, onOutWidget: onOutWidget, onChange: onChange});
// Load Contents
var widget_1 = Ajax_Load('widget_1');
// Load Default Widgets
portal.add(new Xilinus.Widget().setTitle("News Widget #1").setContent(widget_1), 0);
// Add controls buttons
portal.addWidgetControls("control_buttons");
}
Event.observe(window, "load", init);
widget_1.php
<?php echo "Hello World!"; ?>
When the site loads, i see the widgets and they are working fine (as in they are dragable and each widget can be closed etc). The problem is, the contents from the .php file is not being loaded via ajax and put into the widget.
Where I am I going wrong? Can someone shed some light on this please. Thank you.
