0

http://starodaj.eu/apitest/index2.html查看我的代码

单击“显示可用性”。它应该填充输入。我有一个问题(可能是异步的),所以我无法通过单击填充所有内容。当我多次单击“ShowAvailability”时 - 一切正常。我该如何解决?

    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]);
             }
         }
     });
    }
4

1 回答 1

1

您的脚本使用这些行产生错误

jsonpCallback: "jsonpCallback3",
jsonpCallback: "jsonpCallback",
jsonpCallback: "jsonpCallback2",

当我删除它们时,它只会填满整个桌子

于 2012-08-02T11:06:21.633 回答