Unable to get proper response in ajax call, returning HTML response instead json.
Hello,
I am trying to bring a custom chart in thingworx, It is a out of the scope of thingworx widgets so am developing it using HTML,JS and viewing through webframe widget. Whenever I call thingworx services it is returning HTML response instead json. Please find the sample code below.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>
</head>
<body>
<button onclick="callme()">click</button>
<p id="results">check here</p>
<script>
function callme(){
$.ajax({
type: 'POST',
contentType: "application/json;charset=utf-8",
accept: "application/json;charset=utf-8",
url : 'https://localhost:8443/Thingworx/Things/test/Services/parseData',
success: function(response){
console.log(response);
$("#results").append(response.result);
}
});
}
</script>
</body>
</html>
Here, The service parseData() is returning HTML response though the accept type json. I could able to get json response in postman.
Please let me know what went wrong.
Regards,
Janakiraman P
