我正在尝试使用AJAX保存iCal Calendar的ICS文件。
问题是需要传递许多变量,我在很多地方都看到过这样的事情,但我不知道在哪里,如果我这样做,变量就不会通过。
// window.location.href ='phpToICS.php'; // document.location.href ='phpToICS.php';
这是我的代码:
function addToExternalCalendar(Bid,bid,pax,type,timeStamp,stampEnd,timeIn){ //exportexportcal
$.post('phpToICS.php',
{
Bid:Bid,
bid:bid,
pax:pax,
bType:type,
timeStamp:timeStamp,
stampEnd:stampEnd,
timeIn:timeIn
},
function(data,status){
if(status=="success"){
// window.location.href='phpToICS.php';
// document.location.href='phpToICS.php';
jAlert("Exported Succesfully","Success");
}else if(status=="error"){
jAlert("Error EXPORT Failed","Failure");
}
});
}
更新后的代码:
function addToExternalCalendar(Bid,bid,pax,type,timeStamp,stampEnd,timeIn){ //exportexportcal
if(stampEnd==undefined){var stampEnd=timeStamp;}
$.post('phpToICS.php',
{
// data: { Bid:Bid, bid:bid, pax:pax, bType:type, timeStamp:timeStamp, stampEnd:stampEnd, timeIn:timeIn },
Bid:Bid,
bid:bid,
pax:pax,
bType:type,
timeStamp:timeStamp,
stampEnd:stampEnd,
dataType: 'script', // NONE OF THE OPTIONS WORK: "xml", "html", "text", "script", "json", "jsonp" //
timeIn:timeIn
},
// datatype: function(data,status){... } or datatype: function(response,type){... }
// THESE 2 STOP THE SCRIPT
function(data,status){
if(status=="success"){
// window.location.href='phpToICS.php';
// document.location.href='phpToICS.php';
console.log(data);
jAlert("Exported Succesfully","Success");
}else if(status=="error"){
jAlert("Error EXPORT Failed","Failure");
}
}
);
}