phpfox , get value as response from an ajax call

吃可爱长大的小学妹 提交于 2019-12-12 10:25:15

问题


Trying to make an ajax call and get something as response in phpfox .

the JS :

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

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

The function which the ajax calls from within 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

I want to get the value of $counter in data variable. The code does not work but FireBug shows the ajax request with no result returned as response. What is the way ?


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

i Use this function and it return me output in data variable

ajax function in user module

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

}    


来源:https://stackoverflow.com/questions/19996021/phpfox-get-value-as-response-from-an-ajax-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!