使用 cakephp 2.3.0 的简单 ajax 示例 [英] simple ajax example with cakephp 2.3.0

查看:23
本文介绍了使用 cakephp 2.3.0 的简单 ajax 示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,如果有人能给我一个例子如何在cakephp 2.3.0中使用ajax,一个例子是这样的

html->link('Original', '#',array('onclick'=>'return false;', 'id'=>'remanufactured-link', 'class'=>'get-type-product-link'));?><div id="内容">

当我单击 original 链接时,id 为 content 的 div 会发生变化.我怎样才能用 cakephp 2.3.0 做到这一点?

解决方案

见下例:

 $.ajax({数据类型:html",类型:POST",evalScripts: 真,url: '<?php echo Router::url(array('controller'=>'your-controller','action'=>'your-action'));?>',数据:({类型:'原始'}),成功:功能(数据,文本状态){$("#div1").html(数据);}});

please help me, if anyone can give me an example how to use ajax with cakephp 2.3.0 an example is like this

<?php echo $this->html->link('Original', '#', 
                array('onclick'=>'return false;', 'id'=>'remanufactured-link', 'class'=>'get-type-product-link')); ?>   

<div id="content">
</div>

when i click a original link a div with id content is change. how can i do it this with cakephp 2.3.0?

解决方案

See below example:

         $.ajax({
            dataType: "html",
            type: "POST",
            evalScripts: true,
            url: '<?php echo Router::url(array('controller'=>'your-controller','action'=>'your-action'));?>',
            data: ({type:'original'}),
            success: function (data, textStatus){
                $("#div1").html(data);

            }
        });

这篇关于使用 cakephp 2.3.0 的简单 ajax 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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