PDA

View Full Version : Ajax Tabs and PHP calls on external linked pages, how to?



j1vasan007
09-29-2006, 09:55 PM
1) Script Title:
Ajax Tabs
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm
3) Describe problem:
I'm looking to implement this ajax star rating system into my website. This requires a <php include...> at the top of the file that I which to use it and another <php drawrating...> call wherever I want the ratings to appear. This works fine with standalone HTML but I cannot get this to work with ajax tabs.

I've tried passing the JS and CSS files required through the rev attribute but still no luck. I'm not sure where the problem is, will PHP calls not get executed from externally called pages using ajax tabs?

Thanks,
Jay

jscheuer1
09-30-2006, 03:01 AM
will PHP calls not get executed from externally called pages using ajax tabs

No, they won't. PHP is parsed by the server before page is served to (loads in) the browser. Ajax only imports content from a page, not a page. To import a page, use an iframe or frame.

blm126
10-01-2006, 06:15 PM
Yes, PHP calls will get executed if the extention is .php(or whatever your PHP extension is)

jscheuer1
10-02-2006, 01:40 AM
Yes, PHP calls will get executed if the extention is .php(or whatever your PHP extension is)

I wouldn't have thought that possible but, it worked in a trial I just completed. To be clear, the external file is the one that needs the PHP server extension.

I was able to retrieve the current values of this page:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<?php
print "Remote: " . $_SERVER["REMOTE_ADDR"] . "<br>";
print date("F d, Y H:i:s", time());
?>
</body>
</html>

Which I called remote.php when used with Ajax Tabs, like so:


<ul id="maintab" class="shadetabs">
<li class="selected"><a href="#default" rel="ajaxcontentarea">Intro</a></li>
<li><a href="remote.php" rel="ajaxcontentarea">Bird</a></li>
<li><a href="external2.htm" rel="ajaxcontentarea">Dog</a></li>
<li><a href="external3.htm" rel="ajaxcontentarea">Cat</a></li>
<li><a href="external4.htm" rel="ajaxcontentarea">Sea Otter</a></li>
</ul>

Slipped it right into the demo.

blm126
10-02-2006, 01:47 AM
It all comes down to the way AJAX works. AJAX is client side, and therefore the server doesn't even know an AJAX request is happening. Thus, it treats an AJAX request like a normal page request.

jscheuer1
10-02-2006, 02:18 AM
Thus, it treats an AJAX request like a normal page request.

Within limits, only in so far as the body of that page is concerned. At least that is the way Ajax Tabs works. By this I mean to say that data in the head of the Ajax requested page gets ignored one way or the other in the process, things like meta tags, linked style, scripts, etc.

blm126
10-02-2006, 07:41 PM
Within limits, only in so far as the body of that page is concerned. At least that is the way Ajax Tabs works. By this I mean to say that data in the head of the Ajax requested page gets ignored one way or the other in the process, things like meta tags, linked style, scripts, etc.
Yes, but once again it is the difference between the server and the client. It is the client that ignores the meta tags and such, the server can send anything it likes.