JSON, вероятно, будет проще всего, например:
$.ajax({
type: "POST",
data: { id: someIDVariable },
url: "ajax/css.php",
success: function (result) {
$('#bg').css('background-color', result.bg);
$('#font').css('font-color', result.font);
}
});
Или более короткая форма, использующая $.getJSON()
, это GET, опция:
$.getJSON("ajax/css.php", { id: someID }, function (result) {
$('#bg').css('background-color', result.bg);
$('#font').css('font-color', result.font);
});
Тогда в PHP:
eacho json_encode(array('font'=>$font,'bg'=>$bg));
//which will echo this format: { "font": "Arial", "bg": "#000000" }