[問題] ajax 在 php template中的問題

看板Ajax作者 ( MIT I'm comming!)時間14年前 (2012/05/17 23:46), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
我的網站設計的概念是用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

05/18 04:19, , 1F
母檔案貼出來吧
05/18 04:19, 1F
文章代碼(AID): #1FjHraxs (Ajax)
文章代碼(AID): #1FjHraxs (Ajax)