Plivo 获取所有实时呼叫不适用于 jquery 获取请求
Plivo get all live calls not working with jquery get request
我用它来调用 ajax get 请求
// Assign handlers immediately after making the request,
// and remember the jqxhr object for this request
var jqxhr = $.get("https://api.plivo.com/v1/Account/{auth_id}/Call/?status=live", function(data) {
console.log( "success" + data);
})
.done(function(data) {
console.log( "second success" );
})
.fail(function(data) {
console.log( "error" );
})
.always(function(data) {
console.log( "finished" );
console.log(data);
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.always(function() {
alert( "second finished" );
});
})
响应错误,请参见此处 https://www.screencast.com/t/lI6UdQ5H
注意: {auth_id} 我已经用 plivo 提供的 auth_id 替换了它。
感谢您的帮助!
您的代码似乎有效。我在这里做了一个演示。请检查您的 ajax url.
https://jsfiddle.net/aquadk/ez8Lae5v/3/
function mylogger(aValue) {
var theDiv = document.getElementById("msg");
theDiv.innerHTML += aValue + '<br>'
//console.log( "second success" );
}
var USERNAME = 'userid';
var PASSWORD = 'pass'
// Assign handlers immediately after making the request,
// and remember the jqxhr object for this request
var jqxhr = $.ajax({
type: "GET",
url: "https://api.plivo.com/v1/Account/{auth_id}/Call/?status=live",
dataType: 'json',
async: false,
headers: {
"Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD)
},
success: function() {
mylogger("success" + data);
}
})
.done(function(data) {
mylogger("second success");
})
.fail(function(data) {
mylogger("error");
})
.always(function(data) {
mylogger("finished");
mylogger(data);
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.always(function() {
mylogger("second finished");
});
html
<Div id="msg">
</Div>
我用它来调用 ajax get 请求
// Assign handlers immediately after making the request,
// and remember the jqxhr object for this request
var jqxhr = $.get("https://api.plivo.com/v1/Account/{auth_id}/Call/?status=live", function(data) {
console.log( "success" + data);
})
.done(function(data) {
console.log( "second success" );
})
.fail(function(data) {
console.log( "error" );
})
.always(function(data) {
console.log( "finished" );
console.log(data);
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.always(function() {
alert( "second finished" );
});
})
响应错误,请参见此处 https://www.screencast.com/t/lI6UdQ5H
注意: {auth_id} 我已经用 plivo 提供的 auth_id 替换了它。
感谢您的帮助!
您的代码似乎有效。我在这里做了一个演示。请检查您的 ajax url.
https://jsfiddle.net/aquadk/ez8Lae5v/3/
function mylogger(aValue) {
var theDiv = document.getElementById("msg");
theDiv.innerHTML += aValue + '<br>'
//console.log( "second success" );
}
var USERNAME = 'userid';
var PASSWORD = 'pass'
// Assign handlers immediately after making the request,
// and remember the jqxhr object for this request
var jqxhr = $.ajax({
type: "GET",
url: "https://api.plivo.com/v1/Account/{auth_id}/Call/?status=live",
dataType: 'json',
async: false,
headers: {
"Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD)
},
success: function() {
mylogger("success" + data);
}
})
.done(function(data) {
mylogger("second success");
})
.fail(function(data) {
mylogger("error");
})
.always(function(data) {
mylogger("finished");
mylogger(data);
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.always(function() {
mylogger("second finished");
});
html
<Div id="msg">
</Div>