, , . , ...: -)
jQuery, :
$(function() {
$.getJSON('/some/page',{foo:bar,bar:foo},function(json) {
if(json.outcome == 'success') {
$('body').prepend(json.html);
} else {
alert(json.error);
}
});
});
(PHP ), :
<?php
echo json_encode(array('outcome'=>'success','html'=>$output));
echo json_encode(array('outcome'=>'error','error'=>'Uh oh... something is broken'));
, , - - . . , , json. HTML, - , , " " - , ... ... .
, , , , ( ) HTML DOM , JSON , , , . , , - , . HTML JSON.
jQuerying: -)