我通过Ajax通话发布了一些数据并获得了“TOKEN”#39;在获取响应对象后,应该发布到另一个URL以获取<iframe>
中的Tableau视图。以下是我的代码和错误:
代码:
<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Tableau Template</title>
<head>
<meta charset="ISO-8859-1">
<title>Tableau Template</title>
<!-- Vendor Script -->
<!-- Commmon Script -->
<script>
function getTicket() {
try {
alert("Get Ticket");
var tableauInfo = {
username: "10162492",
site_root: "POC1",
// client_ip:"66.145.223.55"
}
//$('#getTicket').html('sending..');
var dashboardResourceURL = "https://analytics.xxxxxxxxxxxx/trusted/##TOKEN##/t/POC1/views/ExampleVis/Dashboard1?:iid=1"
var resourceURL = "https://xxxxxxxxxx/ticket1.php"
$.ajax({
method: 'POST',
url: resourceURL,
// data: JSON.stringify(tableauInfo),
dataType: 'json',
contentType: 'text/html',
headers: {
"Access-Control-Allow-Origin": "http://localhost:8080",
"Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Content-Range, Content-Disposition, Content-Description"
},
crossDomain: true,
})
.success(function(result) {
console.log(result);
alert(Json.stringify(result));
dashboardResourceURL.replace("##TOKEN##", result);
alert(dashboardResourceURL);
$('#tokenurl').show();
$('#tokenurl').src = dashboardResourceURL;
$('#getTicket').html(data.msg);
return result;
})
.fail(function(data) {
console.log('failed!! ', data);
$('#getTicket').html("Error retrieving ticket from Tableau server");
});
} catch (err) {
console.log('an unforseen error occurred; it is ', err);
}
}
</script>
</head>
<body>
<div>
<div>
<h3>Tableau Ticket</h3>
<br />
<div>
<button type="submit" onclick="getTicket();">Get Tableau
Ticket</button>
</div>
<br /> <br />
<div id="getTicket"></div>
</div>
<iframe id="tokenurl" src="" style="display: none;"> </iframe>
</div>
</body>
</html>
错误:失败!!对象{readyState = 4,responseText =&#34; ARCIMBGAn1wNxxu3932mJ8GW&#34;,状态= 200,更多......}
请告诉我我在这里失踪的事情..