我正在尝试使用 XMLHTTP 获取 PDF 文件以进行响应,并使用 XMLHTTP get 发布响应。Get 部分运行良好,但 Post 部分没有得到响应。
var Req = new XMLHttpRequest();
Req.open("POST",'http://192.168.56.103/API/Twebservice.asmx/Updatepdf', false);
Req.onload = function (oEvent) {
// Uploaded.
var blob = function(){var xhr = new XMLHttpRequest()
xhr.open("GET", "http://www.pdf995.com/samples/pdf.pdf",true);
xhr.send();
if (xhr.status === 200) {
var test=xhr.responseText;//console.log(test)
}} }
//GetPDF();
Req.send(blob());
希望有人可以提供帮助。
将调用视为异步调用。第一个完成后调用第二个。
function firstCall() {
var xhr = new XMLHttpRequest()
xhr.open("GET", "path1", true);
xhr.onload = function () {
secondCall(xhr.responseText);
};
xhr.onerror = function () {
console.error("Error", xhr.statusText);
};
xhr.send();
}
function secondCall(data) {
var xhr = new XMLHttpRequest()
xhr.open("POST", "path2", true);
xhr.onload = function () {
console.log("done");
};
xhr.onerror = function () {
console.error("Error", xhr.statusText);
};
xhr.send(data);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句