我正在使用PJAX,它对于简单的示例非常有用,但是我需要能够使用PJAX请求做一些高级的事情。
我有以下的..。
var people = [{ first: "John", last: "Doe" }, { first: "Jane", last: "Smith" }];
$("a.sheet-link").pjax("#content");
$('#content').on('pjax:beforeSend', function (e, jqXHR, settings) {
// Modify ajax request here?
// Would like to append the people array to data
// Would like to POST rather than GET
// May need to change content-type to "application/json".
});我尝试过各种方法..。
使用stick.)
所有的尝试都给了我各种各样的问题。
我不知道为什么这么难。任何帮助都将不胜感激!
发布于 2012-04-30 23:38:27
既然documentation指出:
,您也可以直接调用$.pjax。它的功能非常类似于$.ajax,甚至返回相同的东西并接受相同的选项。
我将尝试以下几点:
var people = [{ first: "John", last: "Doe" }, { first: "Jane", last: "Smith" }];
$('a.sheetlink').click(function(e) {
e.preventDefault();
$.pjax({
type: 'POST',
url: $(this).href,
container: '#content',
data: people,
dataType: 'application/json'
})
});https://stackoverflow.com/questions/10260599
复制相似问题