|
|
911
Paranoid (IV) Inmate
From: Stuttgart, Germany Insane since: Apr 2001
|
posted 10-02-2001 10:16
i know that XMLHTTP is a microsoft thing, but i want to know ,if there is something similar for linux.
|
bitdamaged
Maniac (V) Mad Scientist
From: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 10-02-2001 18:35
It's my understanding that it's not so much a server side thing as a client side (IE) thing
It should work fine with any server side language. It's my understanding that there is no real hard rule that you must send XML except MS is wrapping this into its .NET package.
THis is fairly self explanitory the only question I have is what the third field in the "Open" method ("false") is for
Here's the basic JS (from http://www.15seconds.com/issue/991125.htm)
function sendData(){
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST", "http://www.yoursite.com/thispage.asp", false);
xmlhttp.Send("<timesheet>An impossibly useless timesheet fragment</timesheet>");
divDisplay.innerHTML=xmlhttp.responseText;
}
:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:
|
mr.maX
Maniac (V) Mad Scientist
From: Belgrade, Serbia Insane since: Sep 2000
|
posted 10-02-2001 21:08
Bitdamaged is right, XMLHTTPRequest object is used only on client side, so you can use almost anything that can send & receive XML through HTTP protocol. You can even write your own handler...
Also, Bitdamaged, here's explanation of open method (copied directly from MS XML SDK)
open Method
Initializes a Microsoft.XMLHTTP request and specifies the method, URL, and authentication information for the request. After calling this method, you must call send to send the request and data (if any) to the server.
oXMLHttpRequest.open(method, url, async, user, password)
Parameters
method
String. HTTP method used to open the connection, such as GET, POST, PUT, or PROPFIND.
url
String. Requested URL. This must be an absolute URL, such as "http://Myserver/Mypath/".
async [optional]
Boolean. Indicator of whether the call is asynchronous. The default is True (the call returns immediately). If set to True, attach an onreadystatechange callback so that you can tell when the send call has completed.
user [optional]
Name of the user for authentication. If this parameter is Null ("") or missing and the site requires authentication, the component displays a logon window.
password [optional]
Password for authentication. This parameter is ignored if the user parameter is Null ("") or missing.
Remarks
The values of the request headers, request body, response headers, and response body must be cleared before calling this method.
Example
The following JScript example creates an HttpRequest object, and then uses the open method to synchronously open an ASP page. It then posts an XML document to an ASP page, which uses the loadXML method to load it.
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("http://myserver/save.asp", false);
xmlHTTP.send(xmlDoc)
<% xmlDoc.loadXML(Request); %>
|
Slime
Lunatic (VI) Mad Scientist
From: Massachusetts, USA Insane since: Mar 2000
|
posted 10-02-2001 21:20
Funny that this came up, it's exactly what the Quek thing uses.
Is it possible to respond to the request with something other than ASP? Like, Perl, for instance? Will the XML string just be readable through STDIN?
|
mr.maX
Maniac (V) Mad Scientist
From: Belgrade, Serbia Insane since: Sep 2000
|
posted 10-02-2001 21:27
You can use any server-side language, since you'll receive raw XML through specified HTTP method (either GET or PUT)...
|
bitdamaged
Maniac (V) Mad Scientist
From: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 10-02-2001 22:59
why are all the posts ending in that +linux
|
mr.maX
Maniac (V) Mad Scientist
From: Belgrade, Serbia Insane since: Sep 2000
|
posted 10-02-2001 23:17
If you take a look at the HTML code, you'll see why, heh... Anyway, you'll see that doc has added <!-- --> tags around link that will reveal poster's IP address (the famous "whirr!" link) and since this topic's name conatins "-->" comment will be ended a little sooner, and the rest will be visible...
|
GRUMBLE
Paranoid (IV) Mad Scientist
From: Omicron Persei 8 Insane since: Oct 2000
|
posted 10-02-2001 23:17
a virus?
a bug in infopops UBB?
a bad joke by doc?
|
GRUMBLE
Paranoid (IV) Mad Scientist
From: Omicron Persei 8 Insane since: Oct 2000
|
posted 10-02-2001 23:21
ah, simultaneous post, max.
but very interesting!
maybe there are also other html-tags which could affect the page-design. (harharhar )
*hops over to the unregistered forum*
|
bitdamaged
Maniac (V) Mad Scientist
From: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 10-03-2001 03:49
Woohoo.
Okay this got me wondering so I tried put a little proof of concept together.
I have 2 files. The first is my php script and woohoo is it complicated here we go:
<?
if (isset($testing)) echo "This is the test variable:<br> ".$testing."<p>";
?>
okay I saved that as "testing.php"
Then I have my HTML file that looks like this:
<html>
<head>
<script language=javascript>
function testXMLHTTP(){
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST", "http://www.bitdamaged.com/testpages/xmlhttp/testing.php", false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.Send('testing='+dainput.value);
testDIV.innerHTML+=xmlhttp.responseText;
}
</script>
</head>
<body>
<input type="text" name="dainput" value="test">
<a href="javascript:testXMLHTTP()">Click me!</a>
<p>
<div id="testDIV">
</div>
</body>
</html>
When I first tried this with the code I posted earlier I kept getting this error
Fatal error: No content-type in POST request in [no active file] on line 0
After quite a bit of searching I found this bit
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
Which of course set the missing header. After adding that it worked like a champ.
Here's the sample page
http://www.bitdamaged.com/testpages/xmlhttp/xmlhttptest.html
:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:
|
mr.maX
Maniac (V) Mad Scientist
From: Belgrade, Serbia Insane since: Sep 2000
|
posted 10-03-2001 08:11
Bitdamaged, you should download XML SDK from Microsoft's web site, so that you can have complete reference for MS XML parser...
|
911
Paranoid (IV) Inmate
From: Stuttgart, Germany Insane since: Apr 2001
|
posted 10-03-2001 12:50
ok ok, i was wrong.
i thought xmlhttp is a server-side-thing, but it is a client-side-thing. i think i am right if i say, that xmlhttp is used to make a connection from the browser to a server, to send "information" and receive "information".
|
Slime
Lunatic (VI) Mad Scientist
From: Massachusetts, USA Insane since: Mar 2000
|
posted 10-03-2001 20:05
Woah, woah, wait, you mean that HTML is allowed in the subjects? That's not good.
|
mr.maX
Maniac (V) Mad Scientist
From: Belgrade, Serbia Insane since: Sep 2000
|
posted 10-03-2001 22:07
911, yes, you're right, XMLHTTPRequest class is used to send & receive information from web browser to web server.
Slime, look at the HTML source code of this topic, and you'll see where is the problem...
|
911
Paranoid (IV) Inmate
From: Stuttgart, Germany Insane since: Apr 2001
|
posted 10-04-2001 13:42
bitdamaged: could you please post your php-code here. i want to see how the script on the server looks like.
|
bitdamaged
Maniac (V) Mad Scientist
From: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 10-04-2001 18:53
Actually I did.
In my post above it's all there, all one line of it
<?
if (isset($testing)) echo "This is the test variable:<br> ".$testing."<p>";
?>
All it's looking for is if the testing variable is set and then echos the result.
Remember PHP automatically takes any name=value pairs that get submitted to it and makes them accessible variables.
So this line in the JS :
xmlhttp.Send('testing='+dainput.value);
sends a package to the script that looks like this "testing=whatever"
Since I was just trying to see this work I kept my PHP simple. You could do whatever you wanted with that $testing variable you like.
:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:
|
911
Paranoid (IV) Inmate
From: Stuttgart, Germany Insane since: Apr 2001
|
posted 10-04-2001 19:20
ok, i got it. i tried it first by myself, but i dind´t work. (syntax error ;-)) but now i works fine. this is a really cool functionality, because you can bring "information" to a site without a refresh.
|
bitdamaged
Maniac (V) Mad Scientist
From: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 10-04-2001 19:25
Yeah I have a more advanced version here It should work in all browsers. In non IE compatible browsers it pops up a window with the results, no JS and it goes to a landing page.
:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:
|
Slime
Lunatic (VI) Mad Scientist
From: Massachusetts, USA Insane since: Mar 2000
|
posted 10-04-2001 20:18
This is so cool! Seriously, this is the functionality I've wanted for so long, you can do such cool stuff with this! Load external pages, create chat rooms (such as quek)... multiplayer javascript games, i'm so excited! It works in IE 5.5+, right?
|
DocOzone
Maniac (V) Lord Mad Scientist Sovereign of all the lands Ozone and just beyond that little green line over there...
From: Stockholm, Sweden Insane since: Mar 1994
|
posted 10-05-2001 13:39
What's going on here? I thought I made the whirr! thing go away?
Your pal, -doc-
|
DocOzone
Maniac (V) Lord Mad Scientist Sovereign of all the lands Ozone and just beyond that little green line over there...
From: Stockholm, Sweden Insane since: Mar 1994
|
posted 10-05-2001 13:42
Ah! Somebody used "-->" in the title of this thread, and that bit is getting written into a commented out section, which now stops short! How cool, heh.
(fixed now, hopefully.)
Your pal, -doc-
|