我正在实施照片标记系统。
在我的 php 文件中,我有:
if($_POST['type'] == "insert") {
$pid = $post->ID;
$tag_name = $_POST['tag_name'];
$tag_link = $_POST['tag_link'];
$pic_x = $_POST['pic_x'];
$pic_y = $_POST['pic_y'];
$arr = array("tag_name" => $tag_name, "tag_link" => $tag_link, "pic_x" => $pic_x, "pic_y" => $pic_y);
add_photo_tag($pid, $arr);
wp_redirect("http://www.test.com");
}
捕捉数据。在我的 js 文件中,我有:
$('#tagit #btnsave').live('click',function(){
name = $('#tagname').val();
link = $('#taglink').val();
counter++;
$('#taglist ol').append('<li rel="'+counter+'">'+counter+'. <a href="'+link+'#test_id" target="new">'+name+'</a> (<a class="remove">Entfernen</a>)</li>');
$('#imgtag').append('<div class="tagview" id="view_'+counter+'">'+counter+'</div>');
$('#view_' + counter).css({top:mouseY,left:mouseX});
$('#tagit').fadeOut();
$.ajax({
type: "POST",
url: "content.php",
data: "tag_name=" + name + "&tag_link=" + link + "&pic_x=" + mouseX + "&pic_y=" + mouseY + "&type=insert",
cache: true,
success: function(data) {
alert("success!");
}
});
});
不知何故,变量没有传递给 php,导致我无法将数据正确保存到数据库中。问题必须在 $.ajax 部分或 php 中的某个地方。有人能帮我吗?