mam taki kod
function callApi(acallback) {
// alert(acallback);
$.ajax({
url: acallback,
type: 'GET',
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "jsonpCallback2",
complete: function (response, responseCode) {
console.log(response); console.log(responseCode);
},
success: function (json) {
console.log(json);
var HotelName = "jakasnazwa";
;
$
.each(json
, function (index
, value
) { var contentFromAPI = '<tr><td>' + this.ReservationId + '</td><td>' + HotelName + '</td><td>' + this.CheckInDate + '</td><td>' + this.Total + '</td><td>' + this.CreatedOn + '</td><td>' + this.Status + '</td></tr>';
// alert(contentFromAPI);
$("table.arrival tbody").append(contentFromAPI);
});
},
error: function(response, status, err){
console.log(response.status);
if(response.status == 400){
console.log("Sorry, this is bad request!");
}
if(response.status == 601){
sessionTimedOut();
}
Tylko, ze gdy dostaje error 400
"NetworkError: 400 Bad Request
W konsoli nie ma mojego Sorry, 'this is bad request!'
Jak to ugryźc?
EDIT:
Response body
{
"reason": "date(s) are invalid",
"code": 400
}
Wiem, ze moge poprostu sprawdzic czy code ==400, ale czy nie da sie tego zalatwic poprzez error?
Ten post edytował Twist 4.07.2012, 14:24:11