2015-04-06 76 views
-1

我使用的是X-編輯,我想使用_POST方法簡單的值傳遞給其他頁和我收到此錯誤:X-編輯_ POST方法

注意:未定義指數:FIRST_NAME在...

這裏我的代碼:

這是有這樣的一個簡單的代碼的HTML頁面:

<form method="post" action="update.php"> 
    <a href="#" id="first_name" data-type="text" data-url="/post" data-title="Edit First Name" class="editable editable-click">BILL GATES</a> 
</form> 

這裏我javascript代碼:

$(document).ready(function() { 

//toggle `popup`/`inline` mode 
$.fn.editable.defaults.mode = 'popup';  

//-------------------------------------------------------------------------------------------- 
//First Name 
$('#first_name').editable({   
    validate: function(value) { 
    //Not Empty 
     if($.trim(value) == '') return 'The First Name is required'; 

     //More than 3 and less than 20 
     if($.trim(value.length) <4) return 'The First Name must be more than 3 and less than 20 characters'; 
     //Less than 20 
     if($.trim(value.length) >20) return 'The First Name must be more than 3 and less than 20 characters';   
    } 
}); 

在這裏,我想捕捉的PHP代碼值:

$first_name = $_POST['first_name']; 
echo $first_name."<br>"; 

,我收到此:

Notice: Undefined index: first_name in ...

請任何意見或建議?

問候......

回答

0

在默認情況下,X-編輯您可以通過3個值(ID,名稱,值)

您可以添加這樣

<a href="#" id="first_name" data-type="text" data-url="/post" data-title="Edit First Name" class="editable editable-click" data-name="some_name_here" data-pk="exiting_table_pk">BILL GATES</a> 

$('#first_name').editable({ 
    pk: 1, 
    url: '/post', 
    name: 'some_name_here', 
    title: 'Enter First Name' 
}); 

參考:http://vitalets.github.io/x-editable/docs.html