| Coding Forum Problems with your code? Let's hear about it. |
10-14-2003, 01:33 PM
|
#1 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,816
Latest Blog: None
|
XML HTTP Request, SOAP, XML, PHP...
I am hoping to find someone who has used, the SOAP protocol, XML HTTP Requests, or Server-side XML taslation.
The main goal is to find an alternative to using frames (to change part of a web page while leaving other parts the static).
I want to use a script within the page to download data without the web page actually changing.
The solution does not have to involve XML but I have heard about SOAP and HTTPXMLRequests.
The solution does have to be cross-browser, but I am expecting to have to disregard most old browsers.
If it comes to it, the only hack-solution I have seen is to have an invisible <IFRAME> to load data from pages by changing the src property.
I am also looking into the following...
I would like to use PHP to parse XML documents and trasnlate them with XSLT to HTML (as many (old) browsers can't do this.
My server side processer is PHP, I can't get them to tell me the server OS or software, (maybe there's some PHP that will get me any needed info?).
|
|
|
10-20-2003, 11:17 AM
|
#2 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
I am not overly familiar with Soap, but I am not sure how server side XML translations is going to help you, as it still requires a page load.
Depending on how browser independant you need it to be, you may want to look at innerHTML and DIV. You can do some amazing things with a DIV layer with Internet Explorer, but it quickly gets limiting as you branch out. From what I read you can setup an innerHTML script that works for IE and anything newer than netscape 4 (works in netscape 4 but very buggy). Basically how it works is that without reloading the page you can re-write the HTML inside of an element, in this case a DIV.
Cul
|
|
|
10-20-2003, 11:28 AM
|
#3 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,816
Latest Blog: None
|
That's exactly what I want to do, I just need a way to get the data to put in the div via its .innerHTML property.
|
|
|
10-20-2003, 11:30 AM
|
#4 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,816
Latest Blog: None
|
My only reason for translating XML server-side is the low level of support for XSLT client-side.
|
|
|
10-21-2003, 09:34 AM
|
#5 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
Check this site out. There is better for just innerHTML but I thought this one did a nice job of dealing with the browser issue.
http://www.xs4all.nl/~ppk/js/layerwrite.html
I agree do XML via server side XSLT. I just wasnt sure how it applied to changing page content without a page load. Actually re-reading your last two posts I think I am confused on what I am trying to help you with, and thus perhaps just confusing the issue with stuff you already know. If thats the case, sorry
Cul
|
|
|
10-21-2003, 10:31 AM
|
#6 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,816
Latest Blog: None
|
Yeah I was rather unclear, and asked lot's of questions at the same time! sorry too
The effect I was trying to create has also been brought up on another thread: "Div Include" http://www.internet-marketing-resear...opic.php?t=523
In essence, I want to load data from html files into the page without the browser going to the page.
The same page has to stay in the browser over the whole session, and I want to download and insert data as it is needed.
*edit - Yes I can already do the insertion bit, I need the download bit.
|
|
|
10-21-2003, 10:48 AM
|
#7 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
Well innerHTML is likely your best bet then, though even with the script on that link I posted its going to be flakey in some browsers.
As for reading in the files, how big are they? Could you instead just put the code at the top of the page in a javascript variable and write each one as you need it?
Another thought is what happens if you write PHP into innerHTML?
So say you have:
<div id="mainblock">
<?php gethtml('intro.html'); ?>
</div>
And then when you change the innerHTML of the div 'mainblock' you write in <?php gethtml('part2.html'); ?>, obviously intro.html and part2.html being the files you have on your server. gethtml would just be a function that fopen() and reads in a file. I have no idea if this would work, just tossing out ideas
Cul
|
|
|
10-21-2003, 11:38 AM
|
#8 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,816
Latest Blog: None
|
Quote:
|
Originally Posted by Culland
As for reading in the files, how big are they? Could you instead just put the code at the top of the page in a javascript variable and write each one as you need it?
|
Been there, done that, didn't like the T-Shirt!!
The reson I'm not doing it again is so I can easily update the individual files, and so that you don't have a great big load of data to load when you arrive at the site - that's just silly!
Using PHP would not help in the slightest:
a) PHP code doesn't get to the browser.
b) PHP code can only be executed on the server.
Think of it like an IFRAME it should look and feel the same when browsing the site. But will be different behind the scenes.
|
|
|
10-21-2003, 12:10 PM
|
#9 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
I think I am still missing what you are asking then, as I am not sure why PHP being resolved on the server as a problem. Unless you are front loading all the HTML through javascript, which as you said is a heavy load to start if its big files, the client must go back to the server to reload the DIV, same as if it was going to reload the entire page, which means using PHP to read in HTML files is a viable use. I just tested what I earlier wrote and it works fine in a div (though I missed an echo before the function).
Here is the code for a PHP page. This is just using text and not reading in files, but it uses PHP and javascript to update the DIV block. You would need to make a gethtml function that fopen() and reads an html page to a string and returns that string which in turn is echo'd to the browser. It would work similiar to an iframe, other than its not a seperate frame so your HTML you are inserting wont have its own html, head, body tags, just the meat of the HTML.
[code:1:a55508ef2a]<?php
function gethtml($thenumber){
if($thenumber==1){
return "Testing One";
} else {
return "Testing Two";
}
}
?>
<html>
<head>
<script language="javascript">
function dostuff(){
x = document.getElementById("mainblock");
x.innerHTML = "<?php echo gethtml(2); ?>";
}
</script>
</head>
<body>
<div id="mainblock">
<?php echo gethtml(1); ?>
</div>
<br><br>
<input type="button" onClick="dostuff()" value="Push">
</body>
</html>[/code:1:a55508ef2a]
|
|
|
10-21-2003, 12:54 PM
|
#10 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,816
Latest Blog: None
|
Correct - you still don't understand me.
You thinking of server-side includes (only made with PHP).
I am trying to move everything onto the client.
But like we've said, not all in one go because that could be a large download.
So, what I want to do is download some data from the server to the JavaScript.
I want to use JavaScript to do it, and I already know who to write it into place after I've got it.
|
|
|
10-21-2003, 01:18 PM
|
#11 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
Hmm... guess I dont see the point? Sending text to javascript or inserting text from an include or PHP, it seems like its all the same. Not being critical, genuine curosity.
In any case what about doing exactly what I have done but instead of echoing the HTML you echo the javascript to store it into a string client side, then a call to display it. Then when the script is run again you first check to see if its already been downloaded and stored into javascript, if yes just display it, if no then do the download and display?
Cul
|
|
|
10-21-2003, 01:49 PM
|
#12 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,816
Latest Blog: None
|
Ok I appreciate the help, but I don't see how I can explain it any better.
The point is the user is always in the same page, same HTML document, the content of that page changes only.
Maybe this will help...
I just remembered a tutorial on PPK's site.
"Import XML" er I can't get his site at the moment!
[ http://www.xs4all.nl/~ppk/js/]
|
|
|
10-21-2003, 02:19 PM
|
#13 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
Quote:
|
Originally Posted by LazyJim
The point is the user is always in the same page, same HTML document, the content of that page changes only.
|
This I get and understand, but there is only two ways (not counting user input) to change the content of the page, either its written into the page to start with, ie front loading all the text/html into something like a javascript array, or you are fetching new data from the server via includes, php, etc. You can keep the same HTML page, put everything that changes inside a DIV block that you re-write via innerHTML, but it doesnt get around the fact that you either already have the data client side, or you need to request it from the server.
There is a way to alter the XSL file, thus changing what XML data is displayed to the user, completely with javascript. However it only works in IE, plus it doesnt get around the fact that you need to send all the data via XML, which is the same problem as front loading via javascript. You can do server side XSL transformation, but again this calls for a server query, which basically re-writes your HTML page to a new one.
Guess I am out of ideas.
Cul
|
|
|
10-21-2003, 03:44 PM
|
#14 (permalink)
|
|
Crap Bag
Join Date: 10-12-03
Posts: 1,727
Latest Blog: None
|
Quote:
|
Originally Posted by Culland
Another thought is what happens if you write PHP into innerHTML?
|
You can't do that. There's nothing in any browser that will parse PHP. Parsing PHP is exclusively serverside.
|
|
|
10-21-2003, 03:48 PM
|
#15 (permalink)
|
|
Crap Bag
Join Date: 10-12-03
Posts: 1,727
Latest Blog: None
|
Re: XML HTTP Request, SOAP, XML, PHP...
Quote:
|
Originally Posted by LazyJim
My server side processer is PHP, I can't get them to tell me the server OS or software, (maybe there's some PHP that will get me any needed info?).
|
What's the website?
|
|
|
10-21-2003, 03:53 PM
|
#16 (permalink)
|
|
Inactive
Join Date: 10-12-03
Location: Cranberry Township
Posts: 275
|
Re: XML HTTP Request, SOAP, XML, PHP...
Quote:
|
Originally Posted by LazyJim
[size=14]My server side processer is PHP, I can't get them to tell me the server OS or software, (maybe there's some PHP that will get me any needed info?).
|
[code:1:68c7c368b9]
<?php
phpinfo();
?>
[/code:1:68c7c368b9]
Problem solved.
|
|
|
10-21-2003, 03:55 PM
|
#17 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
Quote:
|
Originally Posted by PhilC
Quote:
|
Originally Posted by Culland
Another thought is what happens if you write PHP into innerHTML?
|
You can't do that. There's nothing in any browser that will parse PHP. Parsing PHP is exclusively serverside.
|
Well I tested and it works, which is likely because writing the DIV causes a server query. See my code above, where I implimented the idea.
Cul
|
|
|
10-21-2003, 03:55 PM
|
#18 (permalink)
|
|
Crap Bag
Join Date: 10-12-03
Posts: 1,727
Latest Blog: None
|
[code:1:055915c9de]<html>
<head>
<title>PHPinfo</title>
</head>
<body bgcolor=#FFFFFF>
<p><? phpinfo() ?></p>
</body>
</html>
[/code:1:055915c9de]
Dunno if this will give you the info you require. It's a whole page that you can upload and load into a browser - it gives you a load of info about the PHP configuration on the server.
|
|
|
10-21-2003, 03:57 PM
|
#19 (permalink)
|
|
Crap Bag
Join Date: 10-12-03
Posts: 1,727
Latest Blog: None
|
You wrote PHP code into a page that is already in the browser, and the browser ran the PHP code? It can't be done. PHP is exclusively serverside. We must be getting at cross-purposes here.
|
|
|
10-21-2003, 04:05 PM
|
#20 (permalink)
|
|
Inactive
Join Date: 10-20-03
Posts: 21
Latest Blog: None
|
Quote:
|
Originally Posted by PhilC
You wrote PHP code into a page that is already in the browser, and the browser ran the PHP code? It can't be done. PHP is exclusively serverside. We must be getting at cross-purposes here.
|
I am not saying the browser is doing it, I am saying that when you do an innerHTML it must query the server because the PHP is being processed, maybe just including the PHP tags causes it to automatically query the server, not sure, I just know if I put this code into a page, and then run it, it works.
[code:1:81dec53d70]<?php
function gethtml($thenumber){
if($thenumber==1){
return "Testing One";
} else {
return "Testing Two";
}
}
?>
<html>
<head>
<script language="javascript">
function dostuff(){
x = document.getElementById("mainblock");
x.innerHTML = "<?php echo gethtml(2); ?>";
}
</script>
</head>
<body>
<div id="mainblock">
<?php echo gethtml(1); ?>
</div>
<br><br>
<input type="button" onClick="dostuff()" value="Push">
</body>
</html>[/code:1:81dec53d70]
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
| | |