如何HTTP Post / HTTP使用JQuery获取并导航到另一个页面 [英] How to HTTP Post / HTTP Get and navigate to another page using JQuery
本文介绍了如何HTTP Post / HTTP使用JQuery获取并导航到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友
我正在使用Full Calender应用程序,当我点击一个事件时,它必须重定向到另一个页面,并发布数据,如事件ID,事件开始,事件结束,用户ID如此,我怎么能在J Query和Full Calender中做到这一点
Hi Friends
I am working with a Full Calender application, in that,while i click in a event it must be redirect to another page and also post the data like event id,event start,event end,user id so on,how can i do that in J Query and Full Calender
推荐答案
我认为你可以做类似的事情这个:
I think you can do something like this :
$('#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;
}
});
您可以使用此方法发布数据:
You can use this method to POST your data :
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);
}
});
这篇关于如何HTTP Post / HTTP使用JQuery获取并导航到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文