我想成立一个小组,这个
顶部的菜单调用不同的ajax函数以显示拇指。单击拇指可以在面板的最后一个框中查看详细信息。
我有这个php
功能
function GetPostPartner(){
$catPartner = "loop_pb_partner";
get_template_part($catPartner);
wp_die();
}
add_action(\'wp_ajax_nopriv_GetPostPartner\', \'GetPostPartner\');
function GetPostEnte(){
$catEnte = "loop_pb_ente";
get_template_part($catEnte);
wp_die();
}
add_action(\'wp_ajax_nopriv_GetPostEnte\', \'GetPostEnte\');
function GetPostColl(){
$catColl = "loop_pb_coll";
get_template_part($catColl);
wp_die();
}
add_action(\'wp_ajax_nopriv_GetPostColl\', \'GetPostColl\');
function GetPostMedia(){
$catMedia = "loop_pb_media";
get_template_part($catMedia);
wp_die();
}
add_action(\'wp_ajax_nopriv_GetPostMedia\', \'GetPostMedia\');
function GetPostDetails(){
$pb_details = $_POST[\'postURL\'];
get_template_part($pb_details);
wp_die();
}
add_action(\'wp_ajax_nopriv_GetPostDetails\', \'GetPostDetails\');
这些都是由这些ajax函数调用的
$(document).delegate(\'h4.homus-partners-global-ajax[data-pb- cat*=pb_partner]\', \'click\', function(event) {
event.preventDefault();
var pb_cat = "pb_partner";
var data = {
\'action\': \'GetPostPartner\',
catURL : "loop_"+ pb_cat,
};
$.post(ajaxURL, data, function(response) {
$( \'ul.homus-partners-section-slide\' ).html(response);
});
});
$(document).delegate(\'h4.homus-partners-global-ajax[data-pb-cat*=pb_ente]\', \'click\', function(event) {
event.preventDefault();
var pb_cat = "pb_ente";
var data = {
\'action\': \'GetPostEnte\',
catURL : "loop_"+ pb_cat,
};
$.post(ajaxURL, data, function(response) {
$( \'ul.homus-partners-section-slide\' ).html(response);
});
});
$(document).delegate(\'h4.homus-partners-global-ajax[data-pb-cat*=pb_coll]\', \'click\', function(event) {
event.preventDefault();
var pb_cat = "pb_coll";
var data = {
\'action\': \'GetPostColl\',
catURL : "loop_"+ pb_cat,
};
$.post(ajaxURL, data, function(response) {
$( \'ul.homus-partners-section-slide\' ).html(response);
});
});
$(document).delegate(\'h4.homus-partners-global-ajax[data-pb-cat*=pb_media]\', \'click\', function(event) {
event.preventDefault();
var pb_cat = "pb_media";
var data = {
\'action\': \'GetPostMedia\',
catURL : "loop_"+ pb_cat,
};
$.post(ajaxURL, data, function(response) {
$( \'ul.homus-partners-section-slide\' ).html(response);
});
});
$(document).delegate(\'li.homus-partners-section-single\', \'click\', function(event) {
event.preventDefault();
var pb_post_id = $(this).data(\'post-id\');
var data = {
\'action\': \'GetPostDetails\',
postURL : "single_pb_post_details",
post_id: pb_post_id
};
$.post(ajaxURL, data, function(response) {
$( \'.homus-partners-detalis\' ).html(response);
console.log(pb_post_id);
console.log(data.postURL);
console.log(response);
});
});
即使上面最后一个ajax调用的控制台返回正确的postid,我的响应始终为0。你可以在这份回购协议中找到整个项目
https://github.com/wanbinkimoon/homus-web.git