作者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