问题
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