2010-03-25 41 views
1

我有一個從ajax請求返回的數據有問題。基本上,當我點擊一個鏈接時,它會運行一個ajax請求,將一些html加載到div中,該部分工作正常,數據加載完成後問題就來了。jQuery ajax鏈接,返回的數據包括從不會提交

加載的html的一部分是一種形式,這種形式工作正常,如果我直接加載頁面,但當它通過ajax加載到div它不會提交,但其餘的鏈接在html工作正常。

這裏是請求遠程HTML數據代碼:

// Ajax to load image editing page 
$('a.editpicture').click(function(e) { 
    e.preventDefault(); 
    var picture = $(this).attr("id") 

    $.ajax({ 
     url: 'http://localhost/digital-xposure/index.php/members/viewpicture/' + picture, 
     success: function(data) { 
      $('#update-picture').html(data); 
     } 
    }); 
}); 

這是它加載的形式:

<form method="post" id="updatepicture" name="updatepicture" action="http://localhost/digital-xposure/index.php/members/editpicture"/> 

     <p>Title<input type="text" name="title" id="title" style="input" value="<?php echo $title; ?>"></P> 
     <p>Album<?php echo $albums;?></p> 
     <p>Description<textarea name="description" id="description" cols="50" rows="5"><?php echo $description; ?></textarea></P> 
      <input type="hidden" name="filename" id="filename" value="<?php echo $filename; ?>" /> 
     <input type="button" name="update-submit" id="update-submit" value="Update details" class="button"> Or <input type="button" onClick="location.href='<?php echo base_url(); ?>index.php/members/deletepicture/<?php echo $filename; ?>'" value="Delete picture" class="button"> 

    </form> 

任何想法,爲什麼表單後不會提交被加載到DIV?任何幫助非常感謝,謝謝。

Calum

+0

你有鏈接? – Grumpy 2010-03-25 20:51:35

+0

沒有頁面錯誤? – 2010-03-25 20:59:01

+0

沒有頁面錯誤,請求的html中的表單只是不提交。 – calumogg 2010-03-25 22:48:14

回答

0

,而不是使用。點擊語法

嘗試重寫你的事件

$('.selector').live('click', function(){....}); 
+0

感謝您的回覆,只是嘗試過,但它仍然沒有提交表格。 – calumogg 2010-03-25 22:46:13

-1

做了查看源代碼來驗證呈現的HTML是存在的。

如果您沒有找到它,請檢查生成的源代碼(Firefox Web開發人員插件具有此功能)以驗證生成的HTML是否存在。

0

你的表格是自閉:

<form method="post" id="updatepicture" name="updatepicture" 
action="http://localhost/digital-xposure/index.php/members/editpicture"/> 

試試這個:

<form method="post" id="updatepicture" name="updatepicture" 
action="http://localhost/digital-xposure/index.php/members/editpicture"> 

火狐可能平常運行時檢測到它,然後失敗時,其使用的嵌入式腳本檢測到它。

祝你好運。