X-Editable _POST方法 [英] X-Editable _POST method

查看:83
本文介绍了X-Editable _POST方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用X-Editable,并且想使用_post方法将简单的值传递给其他页面,并且收到此错误:注意:未定义索引:first_name in ...



这里是我的代码:



这是一个简单的html页面, :

 < form method =postaction =update.php> 
< / form>

这里是我的javascript代码:

<$ p $ ($){
$ b //切换`popup` /`inline`模式
$ .fn.editable.defaults。 mode ='popup';

// ---------------------------------- -------------------------------------------------- --------
//名字
$('#first_name')。editable({
validate:function(value){
//非空
if($。trim(value)=='')return'名字是必需的';

//大于3小于20
if($ .trim(value.length)< 4)return'名字必须大于3且小于20个字符';
//小于20
if($。trim(value.length )> 20)return'名字必须多于3且少于20个字符';
}
});

这里我想捕获php代码中的值:

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

我收到此消息:


注意:Undefined index:first_name in ...


请提供任何建议或建议?



问候...

解决方案

在X可编辑的默认情况下,您可以传递3个值(id,name,value)



你可以像这样添加

 < a href =#id =first_namedata-type =textdata-url =/ postdata-title =Edit First Nameclass =editable editable-clickdata-name = some_name_heredata-pk =exiting_table_pk> BILL GATES< / a> 

  $('#first_name')。editable({
pk:1,
url:'/ post',
name:'some_name_here',
title: '输入名字'
});

请参阅: http://vitalets.github.io/x-editable/docs.html


I'm using X-Editable and I want to pass a simple value to other page using the _post method and I receive this error:

Notice: Undefined index: first_name in ...

Here my code:

this is a simple html page that have this code:

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

Here my javascript code:

$(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';           
    }
});

And here I want to capture the value in the php code:

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

and I receive this:

Notice: Undefined index: first_name in ...

Please any advice or suggestion?

Regards...

解决方案

In X-editable by default you can pass 3 values (id, name, value)

you can add like this

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

or

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

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

这篇关于X-Editable _POST方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆