Clean
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<meta name="robots" content="noindex,nofollow" />
<title>nothing</title>
<script type="text/javascript">
document.domain="tudou.com";
if ( typeof TUI != "object" )
var TUI=
{
};
TUI.ajax = function( s )
{
var options =
{
type: s.type || "GET",
url: s.url || "",
data: s.data || null,
contentType: s.contentType || "application/x-www-form-urlencoded",
username: s.username || null,
password: s.password || null,
timeout: s.timeout || 0,
processData: s.processData || true,
beforeSend: s.beforeSend || function()
{
},
complete: s.complete || function()
{
},
handleError: s.handleError || function()
{
},
success: s.success || function()
{
},
accepts:
{
xml: "application/xml, text/xml",
html: "text/html",
script: "text/javascript, application/javascript",
json: "application/json, text/javascript",
text: "text/plain",
_default: "*/*"
}
};
if ( options.data && options.processData && typeof options.data != "string" )
options.data = httpParam(options.data);
if ( options.data && options.type.toLowerCase() == "get" )
{
options.url += (options.url.match(/\?/) ? "&" : "?") + options.data;
options.data = null;
}
var status, data, requestDone = false, xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
xhr.open( options.type, options.url, true, options.username, options.password );
try
{
if ( options.data )
xhr.setRequestHeader("Content-Type", options.contentType);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("Accept", s.dataType && options.accepts[ s.dataType ] ?
options.accepts[ s.dataType ] + ", */*" :
options.accepts._default );
}
catch(e)
{
}
if ( options.beforeSend )
options.beforeSend(xhr);
var onreadystatechange = function(isTimeout)
{
if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") )
{
requestDone = true;
if (ival)
{
clearInterval(ival);
ival = null;
}
status = isTimeout == "timeout" && "timeout" || !httpSuccess( xhr ) && "error" || "success";
if ( status == "success" )
{
try
{
data = httpData( xhr, options.type );
}
catch(e)
{
status = "parsererror";
}
options.success( data, status );
}
else
options.handleError( xhr, status );
options.complete( xhr, status );
xhr = null;
}
};
var ival = setInterval(onreadystatechange, 13);
if ( options.timeout > 0 )
setTimeout(function()
{
if ( xhr )
{
xhr.abort();
if( !requestDone )
onreadystatechange( "timeout" );
}
}
, options.timeout);
xhr.send(options.data);
function httpSuccess(r)
{
try
{
return !r.status && location.protocol == "file:" || ( r.status >= 200 && r.status < 300 ) || r.status == 304 || r.status == 1223 || TUI.browser.safari && r.status == undefined;
}
catch(e)
{
}
return false;
}
function httpData(r,type)
{
var ct = r.getResponseHeader("content-type");
var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
var data = xml ? r.responseXML : r.responseText;
if ( xml && data.documentElement.tagName == "parsererror" )
throw "parsererror";
if ( type == "script" )
eval.call( window, data );
if ( type == "json" )
data = eval("(" + data + ")");
return data;
}
function httpParam(a)
{
var s = [];
if ( a.constructor == Array )
{
for ( var i = 0;
i < a.length;
i++ )
s.push( a.name + "=" + encodeURIComponent( a.value ) );
}
else
{
for ( var j in a )
s.push( j + "=" + encodeURIComponent( a[j] ) );
}
return s.join("&").replace(/%20/g, "+");
}
return xhr;
}
</script>
|