2010-07-24 30 views
0

不必通過各種等植物學問題了,我無法找到解決我所面臨的問題。AJAX - 笨

我有一個笨的應用程序,它在它的觀點一個具有一種形式,使得AJAX調用提交數據。

我有jQuery代碼工作的兩年AJAX調用,但對於呼叫中的一個,從我監視頭返回未找到錯誤的控制器我通過POST調用的資源。如果我直接加載相同的資源,瀏覽器將加載URL。

這裏是我的代碼

$(document).ready(function() 
{ 
    $("#submit_tag").click(function(){ 
     $("#current_tags").fadeOut("fast"); 
     tag = $("#new_tag").val(); 

      $.ajax({ 
       type: "POST", 
       data: "data="+tag, 
          //This returns a resource not found error 
         url: "<?php echo site_url('user/updatetag/');?>/", 
       success: function(msg) 
       { 
       $("#current_tags").remove(); 
       $("#current_tags").fadeIn("fast"); 
       $("#current_tags").html(msg); 

       } 
       }); 
        }); 
    $("a.single_tag").click(function(){ 
     the_id = $(this).attr('id'); 

      $.ajax({ 
       type: "POST", 
       data: "data="+the_id, 
    //This URL works url: "<?php echo site_url('user/deletetag/');?>/", 
       success: function(msg) 
       { 
        $("#current_tags").fadeIn("slow"); 
        $("#current_tags").html(msg); 

       } 
      }); 

    }); 

}); 

感謝您的時間

+1

請包含您的用戶控制器的CI代碼 – bschaeffer 2010-07-24 03:33:20

回答

0

是什麼#new_tag,是input field/text area/select/similarusual html tag類似div?

如果約input/text area/select/similar,那麼你的AJAX/JS是OK。可能是CI代碼中的問題。

如果usual html tag,那麼你應該得到使用.html()該標籤的價值 -

tag = $("#new_tag").html(); 
0

#new_tag是從我讀從被插入到數據庫中的值一個文本框的ID。

所有CI代碼所做的是回聲「已保存」;

從我看到螢火蟲,它說,它無法加載資源。

編輯:

我解決了問題,但加入了行動POST="(Code Igniter URL)"到其先前失蹤的形式標記。