I have got an issue with passing a json object to ajax at prototype.
here is the situation:
PHP:
<?php
$a = array(k1=>v1, k2=>v2);
$a = json_encode($a);
?>//JS
<script>
var a_js = <?= $a ?>
</script>
<?
echo '<input type:"button" onclick='save(a_js) value='save js''>';
?>
JS
function save(a_json) {
AJAX_ACTIONS_URL = 'ajax_action.php';
params = {
act: 'save_filters_status',
a_json: a_json
};
new Ajax.Request(AJAX_ACTIONS_URL, {
method: 'post',
parameters: params,
onSuccess: function (transport) {
alert(transport.responseText);
}
});
}
Ajax_actions.php
if(var_post('act')=='save_filters_status') {
$x = explode(',',var_post('a_js'));
print_r($x);
}
Now, I don't see any post for a_js
at fire fox, there is no response from the ajax, and I am a bit lost, thanks for your help..
Notice I work at JavaScript prototype frame work..