smiile
10-29-2010, 12:22 PM
Hi to all,
Could someone please point me in the right direction regarding following:
PHP page with a <a></a> link.
Once clicked on the link, JS function is called which triggers $.post to call remote PHP file and get data.
Remote PHP files does some DB queries and returns PHP Object.
Only way I have achieved to return data to JS is:
echo json_encode(array('some_var'=>$object->some->var_data);
I can do echo json_encode(array('some_var'=>$object);
In this case JS receives [object Object] (which is correct).
Now, the question:
How can I convert this return data to something PHP usefull?
It would be 'not done' to have to write 75+ lines of printing JS [object Object] to screen :(
At this moment I have:
function fetch_address(object_id)
{
$.post("<?=site_url();?>/core_page/client/getFlow", { object_id: object_id, language_short: '<?=$this->session->userdata('language_short');?>' },
function(data)
{
$('#object_'+object_id).slideDown('fast');
document.getElementById('object_'+object_id+'_data').innerHTML = data.object_id;
}, "json");
}
However, this shows only 1 variable out of 75 from object (variable object_id).
My point is to (if possible) convert data.object_id in the PHP variable and then I can loop it and present data.
Thanks in advance!
Regards,
Smilie
Could someone please point me in the right direction regarding following:
PHP page with a <a></a> link.
Once clicked on the link, JS function is called which triggers $.post to call remote PHP file and get data.
Remote PHP files does some DB queries and returns PHP Object.
Only way I have achieved to return data to JS is:
echo json_encode(array('some_var'=>$object->some->var_data);
I can do echo json_encode(array('some_var'=>$object);
In this case JS receives [object Object] (which is correct).
Now, the question:
How can I convert this return data to something PHP usefull?
It would be 'not done' to have to write 75+ lines of printing JS [object Object] to screen :(
At this moment I have:
function fetch_address(object_id)
{
$.post("<?=site_url();?>/core_page/client/getFlow", { object_id: object_id, language_short: '<?=$this->session->userdata('language_short');?>' },
function(data)
{
$('#object_'+object_id).slideDown('fast');
document.getElementById('object_'+object_id+'_data').innerHTML = data.object_id;
}, "json");
}
However, this shows only 1 variable out of 75 from object (variable object_id).
My point is to (if possible) convert data.object_id in the PHP variable and then I can loop it and present data.
Thanks in advance!
Regards,
Smilie