JQuery Ajax response variable from php
1 answer
you would do something like:
$.getJSON('ajax_responder.php', function(data){
window.var1 = data.var1;
window.var2 = data.var2;
});
and then in ajax_responder.php
<?php
header('Content-type: application/json');
$var1 = 'foo';
$var2 = 'bar';
$data = array(
'var1' => $var1,
'var2' => $var2
);
echo(json_encode($data));
?>
+6
source to share