|
为了发送它,你必须使用 XMLHTTPRequest 对象。我们创建了一个简单的辅助函数,以支持使用 XMLHttpRequest 对象来调用使用 E4X 的服务。此 execService 函数不仅支持异步方式而且也支持同步方式。
[php]
function execService(url, xml, callback) {
var xmlhttp = new XMLHttpRequest();
var async=false;
if (arguments.length==3) async=true;
xmlhttp.open("POST", url, async);
xmlhttp.setRequestHeader("SOAPAction", "\"\""
xmlhttp.setRequestHeader("Content-Type", "text/xml"
if (async) {
var f = function() {
if (xmlhttp.readyState==4) {
callback(new XML(xmlhttp.responseText));
}
}
xmlhttp.onreadystatechange = f;
}
xmlhttp.send(xml.toString());
if (!async) return new XML(xmlhttp.responseText);
}
............
[/php] |
|