如何HTTP Post / HTTP使用JQuery获取并导航到另一个页面

嗨朋友们
我正在使用一个完整的日历应用程序,因为,当我点击一个事件时,它必须重定向到另一个页面,并发布数据,如事件ID,事件开始,事件结束,用户ID等,我该怎么做在J Query和Full Calender中

我想你可以这样做:

$('#calendar').fullCalendar({ eventClick: function(calEvent, jsEvent, view) { window.location = 'page.php?' + 'id=' + calEvent.id + '&start=' + calEvent.start + '&end=' + calEvent.end + '&user_id=' + calEvent.user_id; } }); 

FullCalendar点击事件

您可以使用此方法POST数据:

 function post_to_url(path, params, method) { method = method || "post"; // Set method to post by default, if not specified. // The rest of this code assumes you are not using a library. // It can be made less wordy if you use one. var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); for(var key in params) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", params[key]); form.appendChild(hiddenField); } document.body.appendChild(form); // Not entirely sure if this is necessary form.submit(); } 

从这里开始 。

如何使用它的一个例子:

 $('#calendar').fullCalendar({ eventClick: function(calEvent, jsEvent, view) { var method = 'POST'; var path = 'page.php'; var params = new Array(); params['event_id'] = calEvent.id; params['event_start'] = calEvent.start; params['event_end'] = calEvent.end; params['event_user_id'] = calEvent.user_id; post_to_url(path, params, method); } }); 

当您连接完整日历时,您需要使用eventClick事件。

 $(your_calendar_selector).fullCalendar({ eventClick: eventClick, }); 

然后你定义一个处理程序,如:

 function eventClick(event) {} 

在该函数中,您可以执行一些简单的操作,例如将window.location.href设置为另一个页面,在查询字符串上传递所需的值,或者对新页面执行POST以序列化所需的事件数据。