I have some code that uses jQuery to make an AJAX call to a non-local server for 'supposed' JSON data. However, I have no way of knowing what the data yet contains, as I am receiving a bad return from the $.parseJSON(varjson)
method.
The HTTP request in my web console indicates the response text is 307 characters long, so is there a way for me to simply check what's in the response?
<script type="text/javascript">
$(document).ready(function (){
$("#button").click(function(){
var url = "http://developer.pw-hq.com/api/session";
var success = function(data){
alert('in function');
var html = [];
/* parse JSON */
//data = $.parseJSON(data);
/* loop through array */
alert(data);
$.each(data, function(index, d){
html.push(
"Device Secret : ", d.deviceSecret, ", ",
"Name : ", d.name, ", ",
"ID : ", d.id, ", ",
"Role : ", d.role, ", ",
"Trust Level : ", d.trustLevel, ", ",
"E-Mail : ", d.email, ", ",
"Timezone : ", d.timezone, ", ")
});
alert(html);
console.log(data);
$("#return").html(html.join('')).css("background-color", "orange");
};
$.ajax({
type: 'POST',
url: url,
data:{email:"applicant@pw.me.as-a.com", password:"assessmyskillz", deviceId:""},
dataType: "application/json",
crossDomain: true,
cache:false,
success: success,
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
});
Feel free to attempt a solution. The credentials are legitimate. For potential work :-p