Go to http://starodaj.eu/apitest/index2.html to see my code
Click "Show Availability". It should populate inputs. I have a problme (probably with asynchronous) so I can't populate everything by 1 click. When I click 'ShowAvailability' more times - everything work fine. How can I fix that?
function callAPI(yourAPIKey){
var enquiry = "http://api.roomex.com/api/hotel?apiKey=" + yourAPIKey;
//alert(enquiry);
$.ajax({
url: enquiry,
type: 'GET',
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "jsonpCallback2",
complete: function (response, responseCode) {
},
success: function (json) {
$.each(json.Contracts, function (index, contract) {
// alert("Count before increament : " + Count);
// alert(contract.ContractCode);
ContractsArray[Count] = contract.ContractCode;
// alert("Count after increament : " + Count);
// alert("ContractsArray[Count]: " + ContractsArray[Count]);
Count++;
});
for(var i = 0; i < Count; i++){
//alert("ContractsArray[" + i + "]: " + ContractsArray[i]);
getAvailability(yourAPIKey, ContractsArray[i], startDate, endDate);
getRates(yourAPIKey, ContractsArray[i], startDate, endDate);
//alert("Finish of ContractsArray[" + i + "]: " + ContractsArray[i]);
}
}
});
}
ACCEPTED]
Your script produces errors with these lines
jsonpCallback: "jsonpCallback3",
jsonpCallback: "jsonpCallback",
jsonpCallback: "jsonpCallback2",
when I removed them it just fills the entire table