Php 在X-Editable中通过Ajax提交数据
我试图使用Ajax提交数据,但在运行url参数中定义的php脚本时遇到问题。实际上,我从工作中得到了一些基本的例子: Html:Php 在X-Editable中通过Ajax提交数据,php,jquery,html,ajax,x-editable,Php,Jquery,Html,Ajax,X Editable,我试图使用Ajax提交数据,但在运行url参数中定义的php脚本时遇到问题。实际上,我从工作中得到了一些基本的例子: Html: <a href="#" id="username" data-type="text" data-pk="1" data-name="username" data-original-title="Enter username" class="editable">superuser123</a> $('#username').editable({
<a href="#" id="username" data-type="text" data-pk="1" data-name="username" data-original-title="Enter username" class="editable">superuser123</a>
$('#username').editable({
url: 'post.php',
type: 'text',
pk: 1,
name: 'username',
title: 'Enter username'
});
$(document).ready(function() {
//toggle `popup` / `inline` mode
$.fn.editable.defaults.mode = 'inline';
$('.edit').click(function(e){
e.stopPropagation();
var button = $(this).prev('span').attr('id');
$('#'+button).editable('toggle',{
url: 'post.php',
type: 'text',
pk: 1,
name: button,
title: 'Edit category'
});
});
});
这是有效的(post.php
被执行)。但现在我想有更多的可编辑字段,并在单击按钮时运行它们。这是我的html(我正在使用Smarty):
问题是,这会创建可编辑字段,但它不会调用
post.php
script(与第一个示例不同)。我做错了什么?我通过以下操作解决了这个问题:
$('#' + button).editable({
url: 'post.php',
type: 'text',
name: button,
title: 'Edit category',
ajaxOptions: {
type: 'post'
},
// success: function(data) {
// alert(data);
// },
});
谢谢你发布这个。它真的帮助了我。乔治·艾瓦兹
$('#' + button).editable({
url: 'post.php',
type: 'text',
name: button,
title: 'Edit category',
ajaxOptions: {
type: 'post'
},
// success: function(data) {
// alert(data);
// },
});