PDA

View Full Version : dynamic ajax content



Chadi
04-10-2006, 06:16 AM
I cannot figure out how to use the 'load external link' option in the Dynamic Ajax Content Script.

I put this link;

<a href="javascript:ajaxpage(siteuptime.com+'/prem_statistics.php?Id=28395&UserId=42771', 'rightcolumn');" style="text-decoration: none">

That did not work. I also put

<a href="javascript:ajaxpage('http://siteuptime.com/prem_statistics.php?Id=28395&UserId=42771', 'rightcolumn');" style="text-decoration: none">

Nothing happens when the link is clicked on. Please assist. Thank you

NXArmada
04-10-2006, 04:39 PM
whats the name of the DIV code?

Chadi
04-10-2006, 05:50 PM
http://dynamicdrive.com/dynamicindex17/ajaxcontent.htm

NXArmada
04-10-2006, 06:51 PM
taken from the site:



<a href="javascript:ajaxpage('test.htm', 'contentarea');">test</a>
<div id="contentarea"></div>

Chadi
04-11-2006, 01:29 AM
Let's try this again. To quote myself

"I cannot figure out how to use the 'load external link' option in the Dynamic Ajax Content Script."

Taken from the site:

<a href="javascript:ajaxpage(rootdomain+'/mydir/index.htm', 'contentarea');">test</a>
<div id="contentarea"></div>

I'm not 100% understanding the method above. Any help is appreciated

ddadmin
04-11-2006, 01:57 AM
Firstly, just to make sure you understand, the "load external link" feature refers to loading a page that's still on your own server, just that the syntax is external ("http://"). Due to security reasons Ajax doesn't let you load an offsite link (ie: yahoo.com).

With that said, the code:


<a href="javascript:ajaxpage(rootdomain+'/mydir/index.htm', 'contentarea');">test</a>
<div id="contentarea"></div>

would mean load:


http://www.mysite.com/mydir/index.htm

where "mysite.com" is your site's root domain. The reason for this wierd syntax is that your page may be accessed either with or without the "www" portion, and that matters to Ajax.

Chadi
04-11-2006, 10:53 PM
Thank you for clarifying this.

Is there any possiblity to work around this?

Twey
04-11-2006, 10:56 PM
Is there any possiblity to work around this?Yes, but it requires a server-side script, and doesn't allow for remote hosting. A server-side script can include any site, on any domain, and give its output. If you create such a script, you can include a remote file by means of it.

ddadmin
04-11-2006, 11:50 PM
Not sure if this is what Twey meant, but yes, it is possible, though it would require something like a proxy be set up, using PHP for example. See here (http://developer.yahoo.com/javascript/howto-proxy.html) for a tutorial and sample code.

Twey
04-12-2006, 03:55 PM
it would require something like a proxy be set up, using PHP for example. Close enough.

jackyyll
04-18-2006, 05:03 AM
Hey, how would you go about doing what he said? Like linking to an off server website in the ajax box? Could it be done with like.. a PHP script or something?

Twey
04-18-2006, 09:30 AM
Yes, you can use a simple PHP script to obtain the site:
<?php include("http://www.othersite.com/apage.html"); ?>and then include that page. However, make sure you're very careful to restrict the pages it can access;
<?php include($_GET['page']); ?>is a BIG security risk.