Can not view json api data using ajax and javascript for Outlook plugin

Visitor

I am creating an outlook plugin for one of my projects and I used the Visual Studio VB Outlook Add-In to create the predefined template. The HTML file works well but the script in HTML file has issue processing the ajax success() function. The office libraries do not let the native java script functions run (like alert statements). The data from API can be viewed in console but cannot be caught using a DIV or JSON(stringify) methods.

Here is HTML Code:

<form id="loginform" class="loginform">
<div>
<input type="text" id="server" placeholder="SERVER" required />
</div>
<!--<div>
<input type="text" id="username" placeholder="USERNAME" required />
</div>
<div>
<input type="password" id="password" placeholder="PASSWORD" required />
</div>-->
<button type="submit" id="btnLogin" onclick="return getLogin();">
LOGIN
</button>
</form>

<div>
<p class="apidata"> The API Data is : <br /> </p>
</div>
Here is the script which is in the same HTML File

<script type="text/javascript">
function getLogin() {

var server = document.getElementById("server").value;
var usableURL = "https://customer.xyz.com/biolink/" + server + "/rest/v1/alarms";
$.ajax
({
url: usableURL,
type: "GET",
cors: true,
dataType: 'jsonp',
jsonp: false,
jsonpCallback: 'callback',
crossDomain: true,
contentType: 'application/json; charset=utf-8;',
secure: false,
cache: false,
headers: {
//headers here
},
data: {
"sdate": "2019-05-01T00:00:00",
"ack": "false",
format: "json"
},
success: function (response) {
console.log(response);
alert(response);
$('#apidata').html(JSON.stringify(response));
//var s = $.parseJSON(response.responseText);
document.getElementById("apidata").innerHTML = JSON.stringify(response.responseText);

},
error: function (error) {
console.log(error);
}
})
return false;
}

I can not get the data into DIV here and my data type has to be jsonp because the rest api i am trying has CORS enabled

Any way to solve this view issue?

0 Replies