【问题标题】:phpfox , get value as response from an ajax callphpfox ,从 ajax 调用中获取值作为响应
【发布时间】:2013-11-15 07:47:29
【问题描述】:

尝试进行 ajax 调用并在 phpfox 中获得响应。

JS:

 $.ajaxCall('module.check_whether_first_time',
 'u_id='+u_id+'&my_user_id='+my_user_id).done(function(data) {

        alert(" data  = " + data  )
    });

ajax 从 ajax.class.php 中调用的函数:

    public function check_whether_first_time(){

            $u_id = $this->get('u_id');
            $my_user_id=$this->get('my_user_id');

            // processing with data goes here

            $counter=1;         
            echo $counter;


    }// end of function check_whether_first_time

我想在data 变量中获取$counter 的值。该代码不起作用,但 FireBug 显示 ajax 请求,但没有返回结果作为响应。有什么办法?

【问题讨论】:

  • 试试:$this->call('alert("something");');只是为了检查您的代码是否到达该行。确保您的网站也显示错误

标签: ajax phpfox


【解决方案1】:
{literal}
<script>
function check(u_id,my_user_id)
{
    $.ajaxCall('user.check_whether_first_time','u_id='+u_id+'&my_user_id='+my_user_id).done(function(data)
    {
        alert(" data  = " + data)
    });
}
</script>
{/literal}
<a href="javascript:void();" onclick="check('12','123');">click</a>

我使用这个函数,它会在数据变量中返回我的输出

用户模块中的ajax函数

public function check_whether_first_time(){

            $u_id = $this->get('u_id');
            $my_user_id=$this->get('my_user_id');
            $counter=10;         
            echo $counter.$u_id;
}

【讨论】:

    【解决方案2】:
    $.ajaxCall('organization.getUsersbyid', 'id=' +id+ '&ids=' +ids  +'&idss=' +idss +'&idsss=' +idsss );
    
    public function getUsersbyid() {
    
        $id=$this->get('id');
        $join=1;
    
        $ids=$this->get('ids');
        $idss=$this->get('idss');
        $idsss=$this->get('idsss');
        $add = Phpfox::getService('organization.process')->getUsersbyid($id,$ids,$join,$idss,$idsss);
    
    }    
    

    【讨论】:

    • 你应该详细说明。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-06
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-29
    相关资源
    最近更新 更多