作者linces ( MIT I'm comming!)
看板Ajax
标题[问题] ajax 在 php template中的问题
时间Thu May 17 23:46:42 2012
我的网站设计的概念是用php template的方法 (不晓得可不可以这样说)
总而言之就是
<?php
include header, container, sidebar, footer...
?>
然後 每个部分在独立出去开发
现在我遇到一个问题是
我希望在sidebar中加入一个jquery plugin
但会用到ajax
假设sidebar功能叫 "新增资料"好了 档名是 sb_addName.php
但我的sitemap中 不会出现sb_addName.php让使用者单独执行
只有可能是
domain.com/home.php
domain.com/cool_Stuff.php
domain.com/hot_Girls.php
etc...
这类网页
然而我需要post 资料让我做後续动作
但问题是 我执行之後 确实有post了
可是 我在sidebar.php中拦截不到 $_POST['action']
也因此无法更新资料@@
GOOGLE一个晚上哩~
想说来这里请教看看
或能提供类似的解决方案或关键字也十分感谢
附上程式码
function performAjaxSubmission() {
$.ajax({
url: '',
method: 'POST',
data: {
action: 'save',
field: $(this).attr("db_field"),
val: $(this).attr("db_value")
},
success: function() {
alert("success!");
}
});
return false; // <--- important, prevents the link's href (hash in
this example) from executing.
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.43.102.140
1F:推 Fantasywind:母档案贴出来吧 05/18 04:19