| Interacting with the Internet |
| Author |
Message |
BstrdSmkr
Junior Member
 
Posts: 3
|
|
Interacting with the Internet
This code snippet can be used to send or retrieve information to or from the internet.
In order to communicate with a server from JScript, you first need to know the Universal Resource Indicator (URI) of the server. For example: http://www.mpscripts.net/newthread.php?fid=10
It's worth noting that the "http://" must be included.
Second, you need to know what the server expects to hear from the script. For example the http://www.myspace.com servers will deny your script access if you don't include a header called "Referer" stating where the request is coming from, such as Referer="chrome://myscriptname"
Finally, you need to know what you can expect to hear back from the server. Most of the time knowing what to send and recieve will be trivial because you'll be working with purpose-built scripts. However, if you plan to work with someone else's servers (try to obtain permission first!) such as scraping a web page for information, the server may send the entirity of the page back following your request! At other times you may get something as simple as a yes or no answer, all epending on the intention of your script.
So here's the code and what each piece does:
Code:
var request = new ActiveXObject("Microsoft.XMLHTTP");
var serverResponse = "";
function getData()
{
var TYPE = "GET"; //use GET to request information and POST to send information
var URI = "Http://www.myserverexample.com/form.php"; //whatever server and or form you want to communicate with
var ASYNC = true; //if false script will pause until the request is complete
var TOSERVER = "specific-info-the-server-expects-to-hear"; //info to send to the server
request.open(TYPE, URI, ASYNC);
request.send(TOSERVER);
request.onreadystatechange = processReadyStateChange();
}
function processReadyStateChange()
{
if(request.readyState == 4 && request.status == 200)
{
serverResponse = request.responseText;
}
}
You now have the server's response stored as a string in the variable "serverResponse".
see this web site for more methods and properties of xmlhttp request:
Microsoft Developer's Network
|
|
| 07-14-2006 07:06 AM |
|
 |
vikke
Junior Member
 
Posts: 1
|
|
RE: Interacting with the Internet
Shouldn't it be:
request.onreadystatechange += processReadyStateChange();
|
|
| 10-01-2006 04:06 PM |
|
 |
Silentdragon
MPScripts Staff
     
Posts: 76
|
|
RE: Interacting with the Internet
No, because then it would add the functions name after anything already inside the var. We just want it to use the specified function.
I didn't believe it either, oh wait I did.
|
|
| 10-02-2006 02:28 AM |
|
 |
gerdonhanry
Junior Member
 
Posts: 3
|
|
RE: Interacting with the Internet
Excellent Code Written in order to Interacting with the Internet. I was in need of such a script which will help me in interacting with the Internet.
Web Design Kent
|
|
| 02-24-2010 08:30 PM |
|
 |
heng2bai
Junior Member
 
Posts: 6
|
|
RE: Interacting with the Internet
I have recently join this site and this is nice idea for providing us information about Script Stealer. Would you mind to let us know more about this? Thanks!
gynecomastia surgery
male breast reduction
gynecomastia treatment
[url=http://www.gynecomastiasurgeryreview.com/]how to get rid of man boo
|
|
| 07-05-2010 04:04 AM |
|
 |