Solved

Creating AJAX portlets in Oracle Portal

Posted on 2007-11-27
3
1,593 Views
Last Modified: 2013-12-18
I placed the following code inside an HTML portlet:

<html>
<head>
<script language="JavaScript" type="text/javascript">
var req

function loadURL(url)
{
req=null
if (window.XMLHttpRequest) {
req=new XMLHttpRequest()
}
else if (window.ActiveXObject) {
req=new ActiveXObject("Microsoft.XMLHTTP")
}
if (req!=null) {
req.onreadystatechange=state_Change
req.open("GET",url,true)
req.send(null)
}
else {
document.writeln("Cannot get URL status. Your browser does not support XMLHTTP.")
}
}

function state_Change(){
// if req shows "loaded"
if (req.readyState==4) {
// if OK
if (req.status==200) {
document.getElementById('A1').innerHTML="(Available)"
}
else {
document.getElementById('A1').innerHTML="(Connection Failure)"
}
}
}

</script>
</head>
<body onload="loadURL('http://www.yahoo.com')">

<p>
<b><a href="http://www.yahoo.com">Yahoo test</a> <span id="A1"></span></b>
</p>
</body>
</html>

It works fine offline, but once I put the code into an HTML portlet it doesn't work. I am not getting the security warning pop up so it doesn't look like the xmlhttp request object is being created.

Has anyone been able to get anything similar to work? If not, is there another way I can accomplish this in Portal?
0
Comment
Question by:shadowrox
  • 2
3 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 20368653
Are you sure you get no access permission error or do you only not see the error?
In FireFox look for the error console by entering javascript: as url or by openning menu: Extras->ErrorConsole
In IE look in lover left window corner for the yellow triangle and click on it.

The acces is forbidden because you could fake yahoo.com if your script would be allowed, you see?

0
 

Author Comment

by:shadowrox
ID: 20370137
I ran the debugger. You're right, at  req.open("GET",url,true)  I get 'permission denied'.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 100 total points
ID: 20371788
So the answer to you question here is: what you want to do in browser is not possible when page is loaded from a web server because of security reasons. Do it on web server side scripting by PHP, ASP, Perl or what you have on web server side.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now