我想使用jsonp。
在编写这样的代码时遇到了此错误:
uncaught syntaxerror unexpected token
出什么问题了?
function getAirLine(from , to , date) {
var href = "https://api.flightstats.com/flex/schedules/rest/v1/json/from/"+from+"/to/"+to+"/departing/"+date+"?appId=[myKey1]&appKey=[myKey2]&extendedOptions=languageCode:ko";
$.ajax({
url : href,
dataType: 'jsonp',
success : function(datas) {
console.log(datas);
var dataSet = [];
for (var i = 0; i < datas.scheduledFlights.length; i++) {
for(var j = 0 ; j < datas.appendix.airlines.length ; j++){
if(datas.scheduledFlights[i].carrierFsCode == datas.appendix.airlines[j].fs){
airlines = datas.appendix.airlines[j].name;
}
}
var dataArr = [];
dataArr.push(datas.scheduledFlights[i].departureAirportFsCode);
dataArr.push(datas.scheduledFlights[i].departureTime.substring(11,16))
dataArr.push(datas.scheduledFlights[i].arrivalAirportFsCode)
dataArr.push(datas.scheduledFlights[i].arrivalTime.substring(11,16))
dataArr.push(datas.scheduledFlights[i].carrierFsCode + datas.scheduledFlights[i].flightNumber)
dataArr.push(airlines);
dataSet.push(dataArr);
}
console.log(dataSet);
$('#realTime').DataTable({
destroy: true,
data: dataSet,
columns: [
{ title: "From" },
{ title: "Depart.Time" },
{ title: "To" },
{ title: "Arrial.Time" },
{ title: "AirLine" },
{ title: "AirCode" }
]
});
},
error: function(datas) {
console.log('실패 - ', datas);
}
});
}