0
我想通过ajax添加数据而不使用ajax helper.Here插入工作正常,但问题是插入数据后,我没有看到成功massage.Here是我的努力。Cakephp ajax插入不使用蛋糕ajaxhelper
<script>
$(document).ready(function(){
$('#submit').click(function(){
x=$("#rform").serializeArray();
$.post($("#rform").attr("action"),
x,
function(data)
{
$("#success").html(data);
$("#success").fadeIn();
$("#success").fadeOut(2800);
$("input").val('');
});
$("#rform").submit(function(){
return false;
});
});
});
</script>
这里是add.ctp代码
<?php
echo $this->Form->create('Info',array(
'id' => 'rform'
)); ?>
<fieldset>
<legend><?php echo __('Add Info'); ?></legend>
<?php
echo $this->Form->input('name');
echo $this->Form->input('email');
?>
</fieldset>
<?php
$options = array
(
'label' => 'Add',
'value' => 'Add',
'id' => 'submit'
);
echo $this->Form->end($options);
?>
</div>
<div style="color:green;" id="success">
</div>
这里之后将其添加在bellow.Here再次重复插入页面我需要证明只有成功,我massage.If删除$("#success").html(data);
什么也没有发生,但插入按钮名称后消失。如何在此处添加成功按摩?
莫非你在#submit div中添加一些文本并检查它是否可见?无需提交表单。只需刷新。 – 2014-10-11 16:14:52
您也可以发布服务器上用于处理此请求的方法中的代码 – 2014-10-11 16:22:42